From 736f5b08604c7f02c562784f85d07e429fe70247 Mon Sep 17 00:00:00 2001 From: y-okumura-isp Date: Sun, 14 Mar 2021 19:01:16 +0900 Subject: [PATCH] Support details, summary tags (support-project/knowledge#1089) --- .../io/github/gitbucket/markedj/Grammer.java | 2 +- .../io/github/gitbucket/markedj/MarkedTest.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/gitbucket/markedj/Grammer.java b/src/main/java/io/github/gitbucket/markedj/Grammer.java index 2c33b2b..bceae35 100644 --- a/src/main/java/io/github/gitbucket/markedj/Grammer.java +++ b/src/main/java/io/github/gitbucket/markedj/Grammer.java @@ -12,7 +12,7 @@ public class Grammer { public static String BULLET = "(?:[*+-]|\\d+\\.)"; public static String COMMENT = ""; - public static String TAG = "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b"; + public static String TAG = "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b|details|summary)\\w+(?!:/|[^\\w\\s@]*@)\\b"; public static String CLOSED = "<(" + TAG + ")[\\s\\S]+?<\\/\\1>"; public static String CLOSING = "<" + TAG + "(?:\"[^\"]*\"|'[^']*'|[^'\">])*?>"; public static String HR = "\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))"; diff --git a/src/test/java/io/github/gitbucket/markedj/MarkedTest.java b/src/test/java/io/github/gitbucket/markedj/MarkedTest.java index a6ce24c..de56ed0 100644 --- a/src/test/java/io/github/gitbucket/markedj/MarkedTest.java +++ b/src/test/java/io/github/gitbucket/markedj/MarkedTest.java @@ -204,6 +204,22 @@ public void testEmptyTableCell() throws Exception { "\n", result); } + @Test + public void testDetailsTag() throws Exception { + String result = Marked.marked( + "
\n" + + "sample title\n" + + "long long text\n" + + "
\n"); + + assertEquals( + "

\n" + + "sample title\n" + + "long long text\n" + + "

\n", + result); + } + private String loadResourceAsString(String path) throws IOException { InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(path); try {