Skip to content

Conversation

@silby
Copy link

@silby silby commented Jan 2, 2026

the html rendering is identical to what djoths and thus pandoc do: you get a <span class="symbol">contents</span>. There's an argument for making this a knob and just rendering the symbols as plain text if not requested but I'm not here to add knobs.

PR contains an unrelated tweak to the test helpers which you are free to drop.

Copy link
Owner

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Thanks for figuring out how we should render this as HTML. I think your approach of following pandoc makes a lot of sense 👍

I've left a note inline RE the parsing technique

Ok(#(_, "test")) -> Ok(filepath.join(cases_directory, file))
_ -> Error(Nil)
}
})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we write this as a call to filter with string.ends_with? I think that'd be clearer. Took me a moment to understand what this is doing

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has not been done! It's still using filter_map

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I missed your point about filter vs. filter_map. The filtered list will still need to be mapped (or vice versa) so I figured on saving an iteration.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only runs once per test run with a tiny amount of data so clarity is preferred here 🙏

e.g. vim swap files, which was making it annoying to tweak a test case
because I kept having to close the file for the tests to run.
@silby
Copy link
Author

silby commented Jan 8, 2026

Repushed, thanks.

Copy link
Owner

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, couple more notes inline.


fn parse_symbol(in: String) -> Option(#(Inline, String)) {
take_symbol_chars(in, "")
|> option.map(pair.map_first(_, Symbol))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a case expression instead of combinators please, it is both faster and easier to understand.

// the regexp [-_+a-zA-Z09]+, see:
// https://github.com/jgm/djoths/blob/83dbadd6aa325ff23f0e4144221b0df2c64becc7/src/Djot/Inlines.hs#L213-L221
fn take_symbol_chars(in: String, acc: String) -> Option(#(String, String)) {
case string.pop_grapheme(in) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the iteration technique used in the existing code where the string is pattern matched on 🙏 Pattern matching is very fast, and performance is a priority in this package.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found pop_grapheme in use in comparable iterations in the library so I copied that pattern. I can change it but there is apparently not a unique iteration pattern used in the library so your first review comment to this effect led me to a solution you don’t prefer.

Ok(#(_, "test")) -> Ok(filepath.join(cases_directory, file))
_ -> Error(Nil)
}
})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has not been done! It's still using filter_map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants