• R/O
  • SSH
  • HTTPS

blogs: コミット


コミットメタ情報

リビジョン101 (tree)
日時2019-10-08 20:24:01
作者hirukawa_ryo

ログメッセージ

* flexmark-ext-highlight 0.2.4
flexmark 0.50.40 に変更して「クリップボードへコピー」ボタンが表示されなくなってしまったバグを修正しました。

変更サマリ

差分

--- flexmark-ext-highlight/trunk/src/main/java/net/osdn/blogs/flexmark/ext/highlight/HighlightRenderer.java (revision 100)
+++ flexmark-ext-highlight/trunk/src/main/java/net/osdn/blogs/flexmark/ext/highlight/HighlightRenderer.java (revision 101)
@@ -75,50 +75,50 @@
7575
7676 html.line();
7777
78- BasedSequence info = node.getInfo();
78+ BasedSequence attributes = node.getAttributes();
79+ if(attributes.isNotNull() && !attributes.isBlank()) {
80+ Matcher matcher = ATTRIBUTES_TAG.matcher(attributes);
81+ if (matcher.find()) {
82+ BasedSequence attributesText = attributes.subSequence(matcher.start(1), matcher.end(1)).trim();
83+ if (!attributesText.isEmpty()) {
84+ Matcher attributeMatcher = ATTRIBUTE.matcher(attributesText);
85+ while (attributeMatcher.find()) {
86+ BasedSequence attributeName = attributesText.subSequence(attributeMatcher.start(1), attributeMatcher.end(1));
87+ if (attributeName.isNotNull() && attributeName.length() > 0) {
88+ if (attributeName.charAt(0) == '.') {
89+ BasedSequence cls = attributeName.subSequence(1);
90+ html.attr("class", cls);
91+ if (cls.startsWith("cop")) {
92+ isCopyable = true;
93+ }
94+ } else if (attributeName.charAt(0) == '#') {
95+ html.attr("id", attributeName.subSequence(1));
96+ } else {
97+ BasedSequence attributeValue = attributeMatcher.groupCount() == 1 || attributeMatcher.start(2) == -1 ? BasedSequence.NULL : attributesText.subSequence(attributeMatcher.start(2), attributeMatcher.end(2));
98+ boolean isQuoted = attributeValue.length() >= 2 && (attributeValue.charAt(0) == '"' && attributeValue.endCharAt(1) == '"' || attributeValue.charAt(0) == '\'' && attributeValue.endCharAt(1) == '\'');
99+ if (isQuoted) {
100+ attributeValue = attributeValue.midSequence(1, -1);
101+ }
102+ if (attributeValue.isNotNull()) {
103+ html.attr(attributeName, attributeValue);
104+ }
105+ }
106+ }
107+ }
108+ }
109+ }
110+ }
111+
112+ BasedSequence info = node.getInfo();
79113 if (info.isNotNull() && !info.isBlank()) {
80- Matcher matcher = ATTRIBUTES_TAG.matcher(info);
81- if(matcher.find()) {
82- BasedSequence attributesText = info.subSequence(matcher.start(1), matcher.end(1)).trim();
83- if(!attributesText.isEmpty()) {
84- Matcher attributeMatcher = ATTRIBUTE.matcher(attributesText);
85- while (attributeMatcher.find()) {
86- BasedSequence attributeName = attributesText.subSequence(attributeMatcher.start(1), attributeMatcher.end(1));
87- if(attributeName.isNotNull() && attributeName.length() > 0) {
88- if(attributeName.charAt(0) == '.') {
89- BasedSequence cls = attributeName.subSequence(1);
90- html.attr("class", cls);
91- if(cls.startsWith("cop")) {
92- isCopyable = true;
93- }
94- } else if(attributeName.charAt(0) == '#') {
95- html.attr("id", attributeName.subSequence(1));
96- } else {
97- BasedSequence attributeValue = attributeMatcher.groupCount() == 1 || attributeMatcher.start(2) == -1 ? BasedSequence.NULL : attributesText.subSequence(attributeMatcher.start(2), attributeMatcher.end(2));
98- boolean isQuoted = attributeValue.length() >= 2 && (attributeValue.charAt(0) == '"' && attributeValue.endCharAt(1) == '"' || attributeValue.charAt(0) == '\'' && attributeValue.endCharAt(1) == '\'');
99- if(isQuoted) {
100- attributeValue = attributeValue.midSequence(1, -1);
101- }
102- if(attributeValue.isNotNull()) {
103- html.attr(attributeName, attributeValue);
104- }
105- }
106- }
107- }
108- }
109- info = info.subSequence(0, matcher.start()).trim();
114+ int space = info.indexOfAny(" ");
115+ if (space == -1) {
116+ language = info;
117+ } else {
118+ language = info.subSequence(0, space);
119+ title = info.subSequence(space).trim();
110120 }
111-
112- if (info.isNotNull() && !info.isBlank()) {
113- int space = info.indexOfAny(" ");
114- if (space == -1) {
115- language = info;
116- } else {
117- language = info.subSequence(0, space);
118- title = info.subSequence(space).trim();
119- }
120- languageName = language.unescape();
121- }
121+ languageName = language.unescape();
122122 }
123123 html.srcPosWithTrailingEOL(node.getChars()).withAttr().tag("pre").openPre();
124124
旧リポジトリブラウザで表示