• R/O
  • SSH
  • HTTPS

blogs: コミット


コミットメタ情報

リビジョン88 (tree)
日時2019-02-21 19:43:43
作者hirukawa_ryo

ログメッセージ

* flexmark-ext-highlight 0.1.3 円マークを¥に置換するオプション REPLACE_YEN_SIGN を追加しました。デフォルトで有効です。¥とすることで、Consolasなどの欧文フォントでもバックスラッシュではなく¥マークが表示されるようになります。

変更サマリ

差分

--- flexmark-ext-highlight/trunk/src/main/java/com/vladsch/flexmark/html/renderer/HighlightAccessor.java (revision 87)
+++ flexmark-ext-highlight/trunk/src/main/java/com/vladsch/flexmark/html/renderer/HighlightAccessor.java (nonexistent)
@@ -1,17 +0,0 @@
1-package com.vladsch.flexmark.html.renderer;
2-
3-import com.vladsch.flexmark.ast.FencedCodeBlock;
4-import com.vladsch.flexmark.html.HtmlWriter;
5-import com.vladsch.flexmark.util.options.DataHolder;
6-
7-public class HighlightAccessor extends CoreNodeRenderer {
8-
9- public HighlightAccessor(DataHolder options) {
10- super(options);
11- }
12-
13- @Override
14- public void render(FencedCodeBlock node, NodeRendererContext context, HtmlWriter html) {
15- super.render(node, context, html);
16- }
17-}
--- flexmark-ext-highlight/trunk/src/main/java/net/osdn/blogs/flexmark/ext/highlight/HighlightExtension.java (revision 87)
+++ flexmark-ext-highlight/trunk/src/main/java/net/osdn/blogs/flexmark/ext/highlight/HighlightExtension.java (revision 88)
@@ -6,9 +6,11 @@
66 import com.vladsch.flexmark.html.renderer.NodeRenderer;
77 import com.vladsch.flexmark.html.renderer.NodeRendererFactory;
88 import com.vladsch.flexmark.util.options.DataHolder;
9+import com.vladsch.flexmark.util.options.DataKey;
910 import com.vladsch.flexmark.util.options.MutableDataHolder;
1011
1112 public class HighlightExtension implements HtmlRenderer.HtmlRendererExtension {
13+ public static final DataKey<Boolean> REPLACE_YEN_SIGN = new DataKey<>("REPLACE_YEN_SIGN", true);
1214
1315 private HighlightExtension() {
1416 }
--- flexmark-ext-highlight/trunk/src/main/java/net/osdn/blogs/flexmark/ext/highlight/HighlightRenderer.java (revision 87)
+++ flexmark-ext-highlight/trunk/src/main/java/net/osdn/blogs/flexmark/ext/highlight/HighlightRenderer.java (revision 88)
@@ -41,6 +41,7 @@
4141 "return false;";
4242
4343 private final boolean codeContentBlock;
44+ private final boolean isReplaceYenSign;
4445 private final Highlighter highlighter = new Highlighter(new StyleRendererFactory() {
4546 @Override
4647 public StyleRenderer create(String languageName) {
@@ -50,6 +51,7 @@
5051
5152 public HighlightRenderer(DataHolder options) {
5253 codeContentBlock = Parser.FENCED_CODE_CONTENT_BLOCK.getFrom(options);
54+ isReplaceYenSign = HighlightExtension.REPLACE_YEN_SIGN.getFrom(options);
5355 }
5456
5557 @Override
@@ -65,17 +67,6 @@
6567 }
6668
6769 protected void render(FencedCodeBlock node, NodeRendererContext context, HtmlWriter html) {
68- /*
69- TextCollectingAppendable out = new TextCollectingAppendable();
70- NodeRendererContext subContext = context.getSubContext(out, true);
71-
72- coreNodeRenderer.render(node, subContext, subContext.getHtmlWriter());
73-
74- System.out.println("HTML=<\r\n" + out.getHtml() + "\r\n>");
75-
76- html.append(out.getHtml());
77- */
78-
7970 String languageName = null;
8071 BasedSequence language = BasedSequence.NULL;
8172 BasedSequence title = BasedSequence.NULL;
@@ -156,6 +147,9 @@
156147 if(languageName != null) {
157148 String code = node.getContentChars().normalizeEOL();
158149 CharSequence content = highlight(languageName, code);
150+ if(isReplaceYenSign) {
151+ content = content.toString().replace("\\", "&yen;");
152+ }
159153 html.append(content);
160154 } else {
161155 html.text(node.getContentChars().normalizeEOL());
旧リポジトリブラウザで表示