Skip to content

Commit

Permalink
workaround parsing backticks in markdown code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jan 6, 2025
1 parent a5d9836 commit bda6e53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions site/src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ fn node_view<'a>(node: &'a AstNode<'a>) -> View {
NodeValue::Item(_) => view!(<li>{children}</li>).into_view(),
NodeValue::Paragraph => view!(<p>{children}</p>).into_view(),
NodeValue::Code(code) => {
let mut lit = code.literal.clone();
if lit.contains("<backtick>") {
lit = lit.replace("<backtick>", "`");
}
let mut inputs = Inputs::default();
let (tokens, errors, _) = uiua::lex(&code.literal, (), &mut inputs);
if errors.is_empty() && code.literal != "---" {
let (tokens, errors, _) = uiua::lex(&lit, (), &mut inputs);
if errors.is_empty() && lit != "---" {
let mut frags = Vec::new();
for token in tokens {
let text = token.span.as_str(&inputs, |s| s.to_string());
Expand All @@ -112,7 +116,7 @@ fn node_view<'a>(node: &'a AstNode<'a>) -> View {
frags.push(view!(<Prim prim=prim glyph_only=true/>).into_view())
}
_ => {
frags = vec![view!(<code>{code.literal.clone()}</code>).into_view()];
frags = vec![view!(<code>{lit.clone()}</code>).into_view()];
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion site/text/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ As more and more Uiua code was written, I developed the principle of [Stack-Sour

Long tacit expressions in most array languages can get very unwieldy. Because binary operations are infix, you have to parse the tree structure in your head before you can start determining the order of operations.

For example, in BQN, you can trim matches from the beginning of a string with [`x(∧`∘∊˜¬⊸/⊢)y`](https://mlochbaum.github.io/bqncrate/?q=Remove%20cells%20that%20appear%20in%20x%20from%20beginning%20of%20y#).
For example, in BQN, you can trim matches from the beginning of a string with [`x(∧<backtick>∘∊˜¬⊸/⊢)y`](https://mlochbaum.github.io/bqncrate/?q=Remove%20cells%20that%20appear%20in%20x%20from%20beginning%20of%20y#).

In contrast, here is their equivalent in Uiua, implemented the same way:

Expand Down

0 comments on commit bda6e53

Please sign in to comment.