-
-
Notifications
You must be signed in to change notification settings - Fork 51
Description
currently the definition is as in https://htmlpreview.github.io/?https://github.com/jgm/djot/blob/master/doc/syntax.html#symbols
which says:
Surrounding a word with : signs creates a “symbol,” which by default is just rendered literally ...
so the implementation is highly parser and renderer specific.
- in the Haskell implementation at https://github.com/jgm/djoths/blob/f1ab25c2205f46ab4923ed2a66ed91b4971eda04/src/Djot/Djot.hs#L400C11-L400C65 a word is defined as a literal.
- but here https://github.com/jgm/djoths/blob/f1ab25c2205f46ab4923ed2a66ed91b4971eda04/src/Djot/Inlines.hs#L214 it is:
pSymbol = do
asciiChar ':'
bs <- byteStringOf $ skipSome (skipSatisfyByte
(\c -> c == '+' || c == '-' ||
(isAscii c && isAlphaNum c)))
asciiChar ':'
- in the Lua implemantaion at https://github.com/jgm/djot.lua/blob/a0583ef8270d025b3e86ef521b35f7397cf7215b/djot/inline.lua#L403 a word is defined as
-- 58 = :
[58] = function(self, pos, endpos)
local sp, ep = bounded_find(self.subject, "^%:[%w_+-]+%:", pos, endpos)
if sp then
self:add_match(sp, ep, "symbol")
return ep + 1
else
self:add_match(pos, pos, "str")
return pos + 1
end
end,
so it seems that as least comparing the Haskell and Lua implementations there is some disagreement
Proposal
- allow the syntax of html entities/symbol/emojies -- https://www.w3schools.com/html/html_entities.asp
- allow the syntax of adobe postscript-style glyph names -- https://github.com/adobe-type-tools/agl-specification
- allow the syntax of opentype font glyph names -- https://silnrsi.github.io/FDBP/en-US/Glyph_Naming.html
- allow common naming practices by common css icon-libraries such as Font Awesome Icons, Google Material Design Icons, or Bootstrap Icons (ie.
[a-zA-Z0-9\_\-]+
).
Use-Cases
XML/HTML Renderer
HTML Entity
:apos:
to be rendered as'
:Euro:
to be rendered as&Euro;
HTML Entity Code Point
:#60:
to be rendered as<
or<
:#x2014:
to be rendered as—
or—
or—
or"—"
Icon Font Glyph Name
:fa-bars:
to be rendered as<i class="fa fa-bars"></i>
:fa+fa-bars:
to be rendered as<i class="fa fa-bars"></i>
This may be subject to that actual implementation and/or configuration of the html-renderer backend.
Icon or Symbol Font Glyph Name for PDF, Image, or Unicode Text Renderer
:a19:
to be rendered as "✓" (from Zapf Dingbats font) -- (U+2713 CHECK MARK ✓, ✓
)
Possible Variation
it might be desirable to clearly separate the verbatim html entities from glyph names by using a prefix for indication.
:*a19:
to be rendered as "✓" (from Zapf Dingbats font) -- (U+2713 CHECK MARK ✓, ✓
)
Possible candidates would be : ^
, !
, &
, $
, %
, /
, =
, ?
, +
, ~
, *
, #
So a possible syntax could be in perl-style regular expression:
/^[\^\!\&\$\%\/\=\?\+\~\*\#]?[[:alnum:]\.\_\-\+]+$/
Graceful Fallback Mechanism
where a renderer backend might not be able to recognize which symbol or glyph to actually render it might fallback i the following ways:
pure text style
:apos:
to be rendered as:apos:
:Euro:
to be rendered as:Euro:
:#60:
to be rendered as:#60:
:#x2014:
to be rendered as:#x2014:
:fa-bars:
to be rendered as:fa-bars:
:fa+fa-bars:
to be rendered as:fa+fa-bars:
:a19:
to be rendered as:a19:
:*a19:
to be rendered as:*a19:
html style
:fa-bars:
to be rendered as<code>:fa-bars:</code>
:fa+fa-bars:
to be rendered as<code>:fa+fa-bars:</code>
:a19:
to be rendered as<code>:a19:</code>
:*a19:
to be rendered as<code>:*a19:</code>
Entities that should always be recognized
- Entities as specified as numeric eg.
 
, 
, etc. - https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references