Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support <kbd> in HTML #5796

Closed
jgm opened this issue Oct 6, 2019 · 5 comments · Fixed by #5805
Closed

Support <kbd> in HTML #5796

jgm opened this issue Oct 6, 2019 · 5 comments · Fixed by #5805

Comments

@jgm
Copy link
Owner

jgm commented Oct 6, 2019

See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd

Please press <kbd>Ctrl</kbd>

would better be parsed as a Span with a special class kbd.
The writer should be sensitive to this as well, rendering such spans using <kbd>.

@jgm jgm added this to the 2.8 milestone Oct 6, 2019
@jgm jgm closed this as completed in #5805 Oct 15, 2019
jgm pushed a commit that referenced this issue Oct 15, 2019
* Text.Pandoc.Shared: export `htmlSpanLikeElements` [API change]

This commit also introduces a mapping of HTML span like elements that
are internally represented as a Span with a single class, but that are
converted back to the original element by the html writer. As of now,
only the kbd element is handled this way. Ideally these elements should
be handled as plain AST values, but since that would be a breaking
change with a large impact, we revert to this stop-gap solution.

Fixes #5796.
@salim-b
Copy link
Contributor

salim-b commented Dec 4, 2019

While switching to Pandoc 2.8.x I've noticed that

echo "This is my [key]{.kbd} example" | pandoc --from=markdown --to=markdown-raw_attribute-inline_code_attributes

outputs

This is my [key]{.kbd} example

while

echo "This is my <kbd>key</kbd> example" | pandoc --from=markdown --to=markdown-raw_attribute-inline_code_attributes

outputs

This is my <kbd>key</kbd> example

I think it would be awesome if the former command would produce the same output as the latter since

Markdown allows you to insert raw HTML (or DocBook) anywhere in a document (...)

Currently inline code attributes seem like a one-way road to me...

@jgm
Copy link
Owner Author

jgm commented Dec 5, 2019

Yes, but raw HTML is just passed through as raw HTML; it isn't parsed. (That's by design.)

@salim-b
Copy link
Contributor

salim-b commented Dec 5, 2019

Yes, but raw HTML is just passed through as raw HTML; it isn't parsed. (That's by design.)

Well, since Pandoc 2.8, <kbd> isn't just "passed through" anymore as long as I don't explicitly disable the raw_attribute extension:

echo "This is my <kbd>key</kbd> example" | pandoc --from=markdown --to=markdown

yields:

This is my `<kbd>`{=html}key`</kbd>`{=html} example

@jgm
Copy link
Owner Author

jgm commented Dec 5, 2019

That is just a pandoc-markdown syntax for explicitly marking up raw text in some format.
If you don't like it, disable the raw_attribute extension:

 % echo "This is my <kbd>key</kbd> example" | pandoc --from=markdown --to=markdown-raw_attribute
This is my <kbd>key</kbd> example

@salim-b
Copy link
Contributor

salim-b commented Dec 5, 2019

That is just a pandoc-markdown syntax for explicitly marking up raw text in some format.

OK, I got that.

But somehow I still feel that

echo "This is my [key]{.kbd} example" | pandoc --from=markdown --to=markdown-inline_code_attributes

should then yield

This is my `<kbd>`{=html}key`</kbd>`{=html} example

instead of

This is my [key]{.kbd} example

(as I tried to explain in my first post)

Anyway, feel free to ignore this and focus on more important stuff 😄

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

Successfully merging a pull request may close this issue.

2 participants