• R/O
  • SSH
  • HTTPS

blogs: コミット


コミットメタ情報

リビジョン86 (tree)
日時2019-01-28 19:39:07
作者hirukawa_ryo

ログメッセージ

* flexmark-ext-text-layout-ja 0.1.5 imgのみを含むパラグラフ(p)にclass属性images-onlyを付加するようにしました。

変更サマリ

差分

--- flexmark-ext-text-layout-ja/trunk/src/main/java/net/osdn/blogs/flexmark/ext/text_layout_ja/JapaneseTextLayoutRenderer.java (revision 85)
+++ flexmark-ext-text-layout-ja/trunk/src/main/java/net/osdn/blogs/flexmark/ext/text_layout_ja/JapaneseTextLayoutRenderer.java (revision 86)
@@ -3,7 +3,10 @@
33 import java.util.HashSet;
44 import java.util.Set;
55
6+import com.vladsch.flexmark.ast.HardLineBreak;
7+import com.vladsch.flexmark.ast.Image;
68 import com.vladsch.flexmark.ast.Paragraph;
9+import com.vladsch.flexmark.ast.SoftLineBreak;
710 import com.vladsch.flexmark.html.CustomNodeRenderer;
811 import com.vladsch.flexmark.html.HtmlWriter;
912 import com.vladsch.flexmark.html.renderer.JapaneseTextLayoutAccessor;
@@ -11,6 +14,7 @@
1114 import com.vladsch.flexmark.html.renderer.NodeRendererContext;
1215 import com.vladsch.flexmark.html.renderer.NodeRenderingHandler;
1316 import com.vladsch.flexmark.html.renderer.TextCollectingAppendable;
17+import com.vladsch.flexmark.util.ast.Node;
1418 import com.vladsch.flexmark.util.options.DataHolder;
1519
1620 import net.osdn.blogs.flexmark.ext.text_layout_ja.core.Processor;
@@ -39,9 +43,28 @@
3943 TextCollectingAppendable out = new TextCollectingAppendable();
4044 NodeRendererContext subContext = context.getSubContext(out, true);
4145
42- coreNodeRenderer.render(node, subContext, subContext.getHtmlWriter());
46+ HtmlWriter subHtml = subContext.getHtmlWriter();
47+
48+ boolean isImageOnly = true;
49+ for(Node child : node.getChildren()) {
50+ if(child instanceof Image) {
51+ continue;
52+ }
53+ if(child instanceof SoftLineBreak) {
54+ continue;
55+ }
56+ if(child instanceof HardLineBreak) {
57+ continue;
58+ }
59+ isImageOnly = false;
60+ }
61+ if(isImageOnly) {
62+ subHtml.attr("class", "images-only");
63+ }
64+
65+ coreNodeRenderer.render(node, subContext, subHtml);
4366 html.append(Processor.layout(out.getHtml()));
44-
67+
4568 /*
4669 if (node.getFirstChildAnyNot(NonRenderingInline.class) != null) {
4770 if (!(node.getParent() instanceof ParagraphItemContainer)
旧リポジトリブラウザで表示