From 4cd0ddcb126033ddf47dddd979796a2fde78466d Mon Sep 17 00:00:00 2001 From: abap34 Date: Thu, 8 Aug 2024 01:05:52 +0900 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E4=BA=92=E3=81=AB=E9=A3=9B=E3=81=B9?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20id=20=E3=82=92=E5=89=B2?= =?UTF-8?q?=E3=82=8A=E6=8C=AF=E3=82=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/syntax/FootnoteDefinition.hpp | 9 +++++++-- src/syntax/InlineFootnoteReference.hpp | 13 ++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/syntax/FootnoteDefinition.hpp b/src/syntax/FootnoteDefinition.hpp index 4379326..f99e23e 100644 --- a/src/syntax/FootnoteDefinition.hpp +++ b/src/syntax/FootnoteDefinition.hpp @@ -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 "^" + symbol + "" + childs_html + ""; + std::string label = "label_" + symbol; + std::string jump_to = "ref_" + symbol; + + return std::format( + "[{}]{}", + label, jump_to, symbol, childs_html); } std::map get_properties() const override { return {{"symbol", symbol}}; diff --git a/src/syntax/InlineFootnoteReference.hpp b/src/syntax/InlineFootnoteReference.hpp index de40610..74b18cb 100644 --- a/src/syntax/InlineFootnoteReference.hpp +++ b/src/syntax/InlineFootnoteReference.hpp @@ -16,9 +16,16 @@ struct InlineFootnoteReference : public ASTNode { } std::string to_html() const override { - return " [" + symbol + - "] "; + // 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( + "[{}]" + "", + label, jump_to, symbol); } std::map get_properties() const override {