Skip to content

Conversation

@digitalmoksha
Copy link
Collaborator

Add support for an option, full-info-string, that cmark-gfm supports which allows anything beyond the language specifier on a code block to be added as the data-meta attribute.

Related to #275

@digitalmoksha
Copy link
Collaborator Author

@kivikakk I didn't realize until looking through the current PRs (after I wrote this, of course) that #257 is very similar. Mine doesn't pass the information into the syntax highlighter plugin, and implements an option that mirrors cmark-gfm

Feel free to use one or the other, or something blended.

@digitalmoksha
Copy link
Collaborator Author

Really struggling with the CI failure, https://github.com/kivikakk/comrak/actions/runs/4028558812/jobs/6925581058

---- src/parser/mod.rs - parser::ComrakRenderOptions::full_info_string (line 403) stdout ----
[656](https://github.com/kivikakk/comrak/actions/runs/4028558812/jobs/6925581058#step:4:657)
Test executable failed (exit status: 101).
[657](https://github.com/kivikakk/comrak/actions/runs/4028558812/jobs/6925581058#step:4:658)

[658](https://github.com/kivikakk/comrak/actions/runs/4028558812/jobs/6925581058#step:4:659)
stderr:
[659](https://github.com/kivikakk/comrak/actions/runs/4028558812/jobs/6925581058#step:4:660)
thread 'main' panicked at 'assertion failed: `(left == right)`
[660](https://github.com/kivikakk/comrak/actions/runs/4028558812/jobs/6925581058#step:4:661)
  left: `"<pre><code data-meta=\"extra info\" class=\"language-rust\">fn hello();\n</code></pre>\n"`,
[661](https://github.com/kivikakk/comrak/actions/runs/4028558812/jobs/6925581058#step:4:662)
 right: `"<pre><code class=\"language-rust\" data-meta=\"extra info\">fn hello();\n</code></pre>\n"`', src/parser/mod.rs:10:1
[662](https://github.com/kivikakk/comrak/actions/runs/4028558812/jobs/6925581058#step:4:663)

The order of the attributes on the generated HTML seems to change back and forth. I had even tried to add an additional test, one with github_pre_lang set

    ///
    /// options.render.full_info_string = true;
    /// options.render.github_pre_lang = true;
    /// assert_eq!(markdown_to_html("``` rust extra info\nfn hello();\n```\n", &options),
    ///            "<pre data-meta=\"extra info\" lang=\"rust\"><code>fn hello();\n</code></pre>\n");

and no matter what order I placed the data-meta, it always failed on one of the tests.

In ruby I could just do an expect(markdown_to_html(...)).to include("data-meta=\"extra info\"") and be done with it. Don't know how to achieve that in Rust yet.

@digitalmoksha
Copy link
Collaborator Author

I fixed the test problem I was having. So it looks like everything passes, except for the problem with extensions.txt that was mentioned here

@kivikakk
Copy link
Owner

Thank you very much — this is very clean, and #257 can happily be implemented in terms of this.

I'm going to hackily adjust CI so the footnote issues stop making tests red, then I'll rebase and merge this.

@kivikakk kivikakk force-pushed the add-full-info-string branch from 3dc8ef7 to 1e32a9c Compare February 15, 2023 09:15
@kivikakk kivikakk enabled auto-merge February 15, 2023 09:15
@kivikakk kivikakk merged commit 500a314 into kivikakk:main Feb 15, 2023
@digitalmoksha digitalmoksha deleted the add-full-info-string branch February 15, 2023 15:16
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