Skip to content

Commit

Permalink
Merge pull request #154 from abap34/feat/#153
Browse files Browse the repository at this point in the history
脚注を相互参照するように
  • Loading branch information
abap34 authored Aug 7, 2024
2 parents 9b52db2 + 4cd0ddc commit b3389f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/syntax/FootnoteDefinition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ struct FootnoteDefinition : public ASTNode {
FootnoteDefinition(std::string symbol_) : symbol(symbol_) { set_uuid(); }
std::string to_html() const override {
std::string childs_html = concatenated_childs_html();
return "<span class=\"footnote-def\"><a href=\"#ref_" + symbol +
"\">^" + symbol + "</a>" + childs_html + "</span>";
std::string label = "label_" + symbol;
std::string jump_to = "ref_" + symbol;

return std::format(
"<span class=\"footnote-def\" id=\"{}\"><a "
"href=\"#{}\">[{}]</a>{}</span>",
label, jump_to, symbol, childs_html);
}
std::map<std::string, std::string> get_properties() const override {
return {{"symbol", symbol}};
Expand Down
13 changes: 10 additions & 3 deletions src/syntax/InlineFootnoteReference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ struct InlineFootnoteReference : public ASTNode {
}

std::string to_html() const override {
return "<span class=\"footnote-ref\"> <sup id=\"ref_" + symbol +
"\"><a href=\"#note_" + symbol + "\">[" + symbol +
"]</a></sup> </span>";
// This is correct.
// `label_` is setted in `FootnoteDefinition` (which we have to jump to)
std::string label = "ref_" + symbol;
std::string jump_to = "label_" + symbol;

return std::format(
"<span class=\"footnote-ref\"><sup id=\"{}\"><a "
"href=\"#{}\">[{}]</a>"
"</sup></span>",
label, jump_to, symbol);
}

std::map<std::string, std::string> get_properties() const override {
Expand Down

0 comments on commit b3389f3

Please sign in to comment.