Skip to content

Commit

Permalink
fix emoji test
Browse files Browse the repository at this point in the history
- official spec changed a bit and now do not convert symbols to emoji and just output them as-is
  • Loading branch information
sivukhin committed Dec 21, 2024
1 parent 975b00d commit 87c1504
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions djot_parser/djot_html.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ func (state ConversionState) BlockNodeConverter(tag string, next func(c Children
return state.Writer.InTag(tag, state.Node.Attributes.Entries()...)(content).WriteString("\n")
}

var DefaultSymbolRegistry = map[string]string{
"+1": "πŸ‘",
"smiley": "πŸ˜ƒ",
}
var DefaultSymbolRegistry = map[string]string{}

var DefaultConversionRegistry = map[DjotNode]Conversion{
ThematicBreakNode: func(s ConversionState, n func(c Children)) { s.Writer.OpenTag("hr").WriteString("\n") },
LineBreakNode: func(s ConversionState, n func(c Children)) { s.Writer.OpenTag("br").WriteString("\n") },
TextNode: func(s ConversionState, n func(c Children)) { s.Writer.WriteBytes(s.Node.Text) },
SymbolsNode: func(s ConversionState, n func(c Children)) {
s.Writer.WriteString(DefaultSymbolRegistry[string(s.Node.FullText())])
symbol, ok := DefaultSymbolRegistry[string(s.Node.FullText())]
if ok {
s.Writer.WriteString(symbol)
} else {
s.Writer.WriteString(fmt.Sprintf(":%v:", string(s.Node.FullText())))
}
},
InsertNode: func(s ConversionState, n func(c Children)) { s.InlineNodeConverter("ins", n) },
DeleteNode: func(s ConversionState, n func(c Children)) { s.InlineNodeConverter("del", n) },
Expand Down
2 changes: 1 addition & 1 deletion djot_parser/examples/35.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>My reaction is πŸ‘ πŸ˜ƒ.</p>
<p>My reaction is :+1: :smiley:.</p>

0 comments on commit 87c1504

Please sign in to comment.