parent
d0f7f82787
commit
8d56381012
4 changed files with 67 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Show Lightning CSS warnings (if any) when optimizing/minifying ([#18918](https://github.com/tailwindlabs/tailwindcss/pull/18918))
|
||||
- Use `default` export condition for `@tailwindcss/vite` ([#18948](https://github.com/tailwindlabs/tailwindcss/pull/18948))
|
||||
- Re-throw errors from PostCSS nodes ([#18373](https://github.com/tailwindlabs/tailwindcss/pull/18373))
|
||||
- Detect classes in markdown inline directives ([#18967](https://github.com/tailwindlabs/tailwindcss/pull/18967))
|
||||
|
||||
## [4.1.13] - 2025-09-03
|
||||
|
||||
|
|
|
|||
63
crates/oxide/src/extractor/pre_processors/markdown.rs
Normal file
63
crates/oxide/src/extractor/pre_processors/markdown.rs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
use crate::cursor;
|
||||
use crate::extractor::pre_processors::pre_processor::PreProcessor;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Markdown;
|
||||
|
||||
impl PreProcessor for Markdown {
|
||||
fn process(&self, content: &[u8]) -> Vec<u8> {
|
||||
let len = content.len();
|
||||
let mut result = content.to_vec();
|
||||
let mut cursor = cursor::Cursor::new(content);
|
||||
|
||||
let mut in_directive = false;
|
||||
|
||||
while cursor.pos < len {
|
||||
match (in_directive, cursor.curr) {
|
||||
(false, b'{') => {
|
||||
result[cursor.pos] = b' ';
|
||||
in_directive = true;
|
||||
}
|
||||
(true, b'}') => {
|
||||
result[cursor.pos] = b' ';
|
||||
in_directive = false;
|
||||
}
|
||||
(true, b'.') => {
|
||||
result[cursor.pos] = b' ';
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
cursor.advance();
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Markdown;
|
||||
use crate::extractor::pre_processors::pre_processor::PreProcessor;
|
||||
|
||||
#[test]
|
||||
fn test_markdown_pre_processor() {
|
||||
for (input, expected) in [
|
||||
// Convert dots to spaces inside markdown inline directives
|
||||
(
|
||||
":span[Some Text]{.text-gray-500}",
|
||||
":span[Some Text] text-gray-500 ",
|
||||
),
|
||||
(
|
||||
":span[Some Text]{.text-gray-500.bg-red-500}",
|
||||
":span[Some Text] text-gray-500 bg-red-500 ",
|
||||
),
|
||||
(
|
||||
":span[Some Text]{#myId .my-class key=val key2='val 2'}",
|
||||
":span[Some Text] #myId my-class key=val key2='val 2' ",
|
||||
),
|
||||
] {
|
||||
Markdown::test(input, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ pub mod clojure;
|
|||
pub mod elixir;
|
||||
pub mod haml;
|
||||
pub mod json;
|
||||
pub mod markdown;
|
||||
pub mod pre_processor;
|
||||
pub mod pug;
|
||||
pub mod razor;
|
||||
|
|
@ -14,6 +15,7 @@ pub use clojure::*;
|
|||
pub use elixir::*;
|
||||
pub use haml::*;
|
||||
pub use json::*;
|
||||
pub use markdown::*;
|
||||
pub use pre_processor::*;
|
||||
pub use pug::*;
|
||||
pub use razor::*;
|
||||
|
|
|
|||
|
|
@ -486,6 +486,7 @@ pub fn pre_process_input(content: &[u8], extension: &str) -> Vec<u8> {
|
|||
"cshtml" | "razor" => Razor.process(content),
|
||||
"haml" => Haml.process(content),
|
||||
"json" => Json.process(content),
|
||||
"md" | "mdx" => Markdown.process(content),
|
||||
"pug" => Pug.process(content),
|
||||
"rb" | "erb" => Ruby.process(content),
|
||||
"slim" | "slang" => Slim.process(content),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue