UPDATE Markdown
アスタルテで動いてる最新のMarkdownに追従する更新です。 一応テストしてから実装してください。 今回のアップデートで + 見出しのレイアウト変更 + リストのレイアウトの変更 + 罫線のレイアウトの変更 + より詳細なclass分け + codeのハイライト + 外部サーバー向け画像添付メッセージの表示 + 1件のセキュリティー的な問題の修正 などが変更になっています
This commit is contained in:
parent
0542d92c40
commit
4d4f8b5f52
@ -1,196 +1,266 @@
|
|||||||
.status__content {
|
.status__content {
|
||||||
|
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
max-height: 210px;
|
|
||||||
overflow-x: hidden;
|
h1{
|
||||||
overflow-y: auto;
|
color: #ec840d;
|
||||||
|
font-weight: bold;
|
||||||
h1{
|
font-size: 1.6em;
|
||||||
font-size: 195%;
|
padding: 0.5em;
|
||||||
border-bottom: 2px solid #ff3333;
|
display: inline-block;
|
||||||
}
|
line-height: 1.3;
|
||||||
|
background: #dbebf8;
|
||||||
h2{
|
vertical-align: middle;
|
||||||
font-size: 180%;
|
border-radius: 25px 25px 25px 25px;
|
||||||
border-bottom: 2px solid #ff3333;
|
text-align: center;
|
||||||
}
|
border-bottom: solid 3px #ff0000;
|
||||||
|
}
|
||||||
h3{
|
|
||||||
font-size: 165%;
|
h2{
|
||||||
border-bottom: 2px solid #ff3333;
|
color: #ec840d;
|
||||||
}
|
font-weight: bold;
|
||||||
|
font-size: 1.5em;
|
||||||
h4{
|
padding: 0.5em;
|
||||||
font-size: 150%;
|
display: inline-block;
|
||||||
border-bottom: 2px solid #ff3333;
|
line-height: 1.3;
|
||||||
}
|
background: #dbebf8;
|
||||||
|
vertical-align: middle;
|
||||||
h5{
|
border-radius: 25px 25px 25px 25px;
|
||||||
font-size: 135%;
|
text-align: center;
|
||||||
border-bottom: 2px solid #ff3333;
|
border-bottom: solid 3px #fffb00;
|
||||||
}
|
}
|
||||||
|
|
||||||
h6{
|
h3{
|
||||||
font-size: 120%;
|
color: #ec840d;
|
||||||
border-bottom: 2px solid #ff3333;
|
font-weight: bold;
|
||||||
}
|
font-size: 1.4em;
|
||||||
|
padding: 0.5em;
|
||||||
em{
|
display: inline-block;
|
||||||
font-style: italic;
|
line-height: 1.3;
|
||||||
}
|
background: #dbebf8;
|
||||||
|
vertical-align: middle;
|
||||||
strong{
|
border-radius: 25px 25px 25px 25px;
|
||||||
font-weight: bold;
|
text-align: center;
|
||||||
}
|
border-bottom: solid 3px #2bff00;
|
||||||
|
}
|
||||||
code{
|
|
||||||
display: block;
|
h4{
|
||||||
border-left: 2px solid;
|
color: #ec840d;
|
||||||
border-color: #079903;
|
font-weight: bold;
|
||||||
color: $white;
|
font-size: 1.3em;
|
||||||
padding-left: 10px;
|
padding: 0.5em;
|
||||||
margin-top: 5px;
|
display: inline-block;
|
||||||
margin-bottom: 5px;
|
line-height: 1.3;
|
||||||
margin-left: 5px;
|
background: #dbebf8;
|
||||||
background-color: #000000;
|
vertical-align: middle;
|
||||||
}
|
border-radius: 25px 25px 25px 25px;
|
||||||
|
text-align: center;
|
||||||
pre{
|
border-bottom: solid 3px #00ffea;
|
||||||
display: inline-block;
|
}
|
||||||
font-family: 'Noto Sans Japanese', sans-serif;
|
|
||||||
font-weight: 400;
|
h5{
|
||||||
}
|
color: #ec840d;
|
||||||
|
font-weight: bold;
|
||||||
p ~ blockquote {
|
font-size: 1.2em;
|
||||||
margin-top: -8px;
|
padding: 0.5em;
|
||||||
}
|
display: inline-block;
|
||||||
|
line-height: 1.3;
|
||||||
blockquote{
|
background: #dbebf8;
|
||||||
padding-left: 8px;
|
vertical-align: middle;
|
||||||
margin-top: 0.5em;
|
border-radius: 25px 25px 25px 25px;
|
||||||
margin-bottom: 0.5em;
|
text-align: center;
|
||||||
color: $white;
|
border-bottom: solid 3px #0004ff;
|
||||||
background-color: $ui-base-color;
|
}
|
||||||
display: block;
|
|
||||||
border-left: 4px solid $classic-highlight-color;
|
h6{
|
||||||
}
|
color: #ec840d;
|
||||||
|
font-weight: bold;
|
||||||
ul{
|
font-size: 1.1em;
|
||||||
list-style: inside;
|
padding: 0.5em;
|
||||||
br{
|
display: inline-block;
|
||||||
display: none;
|
line-height: 1.3;
|
||||||
}
|
background: #dbebf8;
|
||||||
}
|
vertical-align: middle;
|
||||||
|
border-radius: 25px 25px 25px 25px;
|
||||||
ul>ul{
|
text-align: center;
|
||||||
br{
|
border-bottom: solid 3px #7700ff;
|
||||||
display: none;
|
}
|
||||||
}
|
|
||||||
}
|
em{
|
||||||
|
font-style: italic;
|
||||||
ul>li>ul{
|
}
|
||||||
padding-left: 1em;
|
|
||||||
list-style: inside circle;
|
strong{
|
||||||
}
|
font-weight: bold;
|
||||||
|
}
|
||||||
ul>li{
|
|
||||||
padding-left: 1em;
|
code{
|
||||||
list-style: inside circle;
|
display: block;
|
||||||
}
|
border-left: 2px solid;
|
||||||
|
border-color: #079903;
|
||||||
ul>br>li{
|
color: $white;
|
||||||
padding-left: 1em;
|
padding-left: 10px;
|
||||||
list-style: inside circle;
|
margin-top: 5px;
|
||||||
}
|
margin-bottom: 5px;
|
||||||
|
margin-left: 5px;
|
||||||
ul>ul>li{
|
background-color: #000000;
|
||||||
padding-left: 2em;
|
|
||||||
list-style: inside circle;
|
.positive{
|
||||||
}
|
color: #5bda57;
|
||||||
|
}
|
||||||
ul>br>ul>br>li{
|
|
||||||
padding-left: 2em;
|
.negative{
|
||||||
list-style: inside circle;
|
color: #ff4949;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol{
|
.rust-fanc{
|
||||||
list-style: inside decimal;
|
color: #ba7eff;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol>li>ol{
|
.ruby-func{
|
||||||
padding-left: 1em;
|
color: #24a8e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
p>a>img{
|
.rust-macro{
|
||||||
width: 100%;
|
color: #d2ff6a;
|
||||||
height: 100%;
|
}
|
||||||
object-fit: contain;
|
|
||||||
}
|
.contents{
|
||||||
|
color: #ff9925;
|
||||||
a>img{
|
}
|
||||||
width: 100%;
|
}
|
||||||
height: 100%;
|
|
||||||
object-fit: contain;
|
pre{
|
||||||
}
|
display: inline-block;
|
||||||
|
font-family: 'Noto Sans Japanese', sans-serif;
|
||||||
p>a{
|
font-weight: 400;
|
||||||
color: #1FBFF9;
|
}
|
||||||
}
|
|
||||||
|
p ~ blockquote {
|
||||||
a{
|
margin-top: -8px;
|
||||||
color: #1FBFF9;
|
}
|
||||||
}
|
|
||||||
|
blockquote{
|
||||||
sup{
|
padding-left: 8px;
|
||||||
font-size: 75.5%;
|
margin-top: 0.5em;
|
||||||
vertical-align: top;
|
margin-bottom: 0.5em;
|
||||||
position: relative;
|
color: $primary-text-color;
|
||||||
top: -0.5em;
|
background-color: $ui-base-color;
|
||||||
}
|
display: block;
|
||||||
|
border-left: 4px solid $classic-highlight-color;
|
||||||
sub{
|
}
|
||||||
font-size: 75.5%;
|
|
||||||
vertical-align: bottom;
|
ul.md-contents {
|
||||||
position: relative;
|
border: double 4px #21b384;
|
||||||
top: 0.5em;
|
padding: 0.5em 1em 0.5em 2.3em;
|
||||||
}
|
position: relative;
|
||||||
|
}
|
||||||
small{
|
ul li.md-contents {
|
||||||
font-size: 50.0%;
|
line-height: 1.5;
|
||||||
vertical-align: bottom;
|
padding: 0.2em 0;
|
||||||
position: relative;
|
list-style-type: none!important;
|
||||||
}
|
}
|
||||||
|
ul li.md-contents:before {
|
||||||
table {
|
font-family: FontAwesome;
|
||||||
margin-top: 0.5em;
|
content: "\f0a4";
|
||||||
margin-bottom: 0.5em;
|
position: absolute;
|
||||||
color: $classic-highlight-color;
|
left : 1em;
|
||||||
display: block;
|
color: #21b384;
|
||||||
width: 100%;
|
}
|
||||||
overflow: auto;
|
|
||||||
border-spacing: 0;
|
ol.md-contents {
|
||||||
border-collapse: collapse;
|
border: double 4px #ff954f;
|
||||||
}
|
padding: 0.5em 1em 0.5em 1em;
|
||||||
|
position: relative;
|
||||||
table tr{
|
list-style: inside decimal;
|
||||||
background-color: #000000;
|
}
|
||||||
}
|
|
||||||
|
ol li.md-contents {
|
||||||
table th, table td{
|
line-height: 1.5;
|
||||||
padding: 6px 13px;
|
padding: 0.2em 0;
|
||||||
border: 1px solid $classic-highlight-color;
|
}
|
||||||
}
|
|
||||||
|
hr {
|
||||||
table th{
|
border-width: 2px 0px 0px 0px;
|
||||||
font-weight: 600;
|
border-style: dashed;
|
||||||
}
|
border-color: #ff7676;
|
||||||
|
height: 1px;
|
||||||
table thead tr{
|
}
|
||||||
background-color: $black;
|
|
||||||
}
|
p>a>img{
|
||||||
|
width: 100%;
|
||||||
td, th{
|
height: 100%;
|
||||||
padding: 0;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
a>img{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
p>a{
|
||||||
|
color: #1FBFF9;
|
||||||
|
}
|
||||||
|
|
||||||
|
a{
|
||||||
|
color: #1FBFF9;
|
||||||
|
}
|
||||||
|
|
||||||
|
sup{
|
||||||
|
font-size: 75.5%;
|
||||||
|
vertical-align: top;
|
||||||
|
position: relative;
|
||||||
|
top: -0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub{
|
||||||
|
font-size: 75.5%;
|
||||||
|
vertical-align: bottom;
|
||||||
|
position: relative;
|
||||||
|
top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
small{
|
||||||
|
font-size: 50.0%;
|
||||||
|
vertical-align: bottom;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
color: $classic-highlight-color;
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
border-spacing: 0;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr{
|
||||||
|
background-color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th, table td{
|
||||||
|
padding: 6px 13px;
|
||||||
|
border: 1px solid $classic-highlight-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th{
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
table thead tr{
|
||||||
|
background-color: $black;
|
||||||
|
}
|
||||||
|
|
||||||
|
td, th{
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.img_FTL {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -88,26 +88,31 @@ class Formatter_Markdown
|
|||||||
%(<h#{header_level}>#{encode(mdContentsRemoved)}</h#{header_level}>\n)
|
%(<h#{header_level}>#{encode(mdContentsRemoved)}</h#{header_level}>\n)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def block_code(code, language)
|
||||||
|
%(<br>#{code.strip})
|
||||||
|
end
|
||||||
|
|
||||||
def codespan(code)
|
def codespan(code)
|
||||||
urlRemoved = "#{remove_url(code)}"
|
urlRemoved = "#{remove_url(code)}"
|
||||||
escapedCode = "#{escape_bbcode(urlRemoved)}"
|
escapedCode = "#{escape_bbcode(urlRemoved)}"
|
||||||
%(<code>#{encode(escapedCode)}</code>)
|
encoded = "#{encode(escapedCode)}"
|
||||||
|
%(<code>#{code_contents(encoded)}</code>)
|
||||||
end
|
end
|
||||||
|
|
||||||
def list(contents, list_type)
|
def list(contents, list_type)
|
||||||
if list_type == :unordered
|
if list_type == :unordered
|
||||||
%(<ul>#{contents.strip}</ul>)
|
%(<ul class='md-contents'>#{contents.strip}</ul>)
|
||||||
elsif list_type == :ordered
|
elsif list_type == :ordered
|
||||||
%(<ol>#{contents.strip}</ol>)
|
%(<ol class='md-contents'>#{contents.strip}</ol>)
|
||||||
else
|
else
|
||||||
%(<#{list_type}>#{contents.strip}</#{list_type}>)
|
%(<#{list_type} class='md-contents'>#{contents.strip}</#{list_type}>)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_item(text, list_type)
|
def list_item(text, list_type)
|
||||||
urlRemoved = "#{remove_url(text)}"
|
urlRemoved = "#{remove_url(text)}"
|
||||||
mdContentsRemoved = "#{markdown_escape(urlRemoved)}"
|
mdContentsRemoved = "#{markdown_escape(urlRemoved)}"
|
||||||
%(<li>#{encode(mdContentsRemoved)}</li>)
|
%(<li class='md-contents'>#{encode(mdContentsRemoved)}</li>)
|
||||||
end
|
end
|
||||||
|
|
||||||
def emphasis(text)
|
def emphasis(text)
|
||||||
@ -170,7 +175,7 @@ class Formatter_Markdown
|
|||||||
if imgcheck !~ /\Ahttps:\/\/[^<>"\[\] ]+\z/
|
if imgcheck !~ /\Ahttps:\/\/[^<>"\[\] ]+\z/
|
||||||
%(#{encode(alt_text)})
|
%(#{encode(alt_text)})
|
||||||
else
|
else
|
||||||
%(<img src="#{URI.encode_www_form_component(link)}">)
|
%(<span class="img_FTL">画像が添付されています。</span><img src="#{URI.encode_www_form_component(link)}">)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -206,7 +211,7 @@ class Formatter_Markdown
|
|||||||
|
|
||||||
#前々から要望があったcode内でBBCodeを無効化するための奴
|
#前々から要望があったcode内でBBCodeを無効化するための奴
|
||||||
def escape_bbcode(string)
|
def escape_bbcode(string)
|
||||||
string.gsub(/\[/){ "[" }
|
string.gsub(/\[/){ "[" }
|
||||||
end
|
end
|
||||||
|
|
||||||
#markdownの中でmarkdownを展開させないためのエスケープする奴
|
#markdownの中でmarkdownを展開させないためのエスケープする奴
|
||||||
@ -221,6 +226,27 @@ class Formatter_Markdown
|
|||||||
string.gsub(/<([\/]?a[^>]*|[\/]?img[^>]*|[\/]?code[^>]*|[\/]?h[1-6][^>]*|[\/]?sup[^>]*|[\/]?sub[^>]*|[\/]?small[^>]*|[\/]?ul[^>]*|[\/]?ol[^>]*|[\/]?li[^>]*|[\/]?hr[^>]*|[\/]?s[^>]*|[\/]?u[^>]*|[\/]?mark[^>]*)>/) { "" }
|
string.gsub(/<([\/]?a[^>]*|[\/]?img[^>]*|[\/]?code[^>]*|[\/]?h[1-6][^>]*|[\/]?sup[^>]*|[\/]?sub[^>]*|[\/]?small[^>]*|[\/]?ul[^>]*|[\/]?ol[^>]*|[\/]?li[^>]*|[\/]?hr[^>]*|[\/]?s[^>]*|[\/]?u[^>]*|[\/]?mark[^>]*)>/) { "" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#code内の一部を色分けするための変更
|
||||||
|
def code_contents(string)
|
||||||
|
simple = string.gsub(/(true|error|false|failed|def|puts|end|fn|let|mut|use|String|println!)/ ,
|
||||||
|
"true" => "<span class='positive'>#{:true}</span>",
|
||||||
|
"error" => "<span class='negative'>#{:error}</span>",
|
||||||
|
"false" => "<span class='negative'>#{:false}</span>",
|
||||||
|
"failed" => "<span class='negative'>#{:failed}</span>",
|
||||||
|
"def" => "<span class='ruby-func'>#{:def}</span>",
|
||||||
|
"puts" => "<span class='ruby-func'>#{:puts}</span>",
|
||||||
|
"end" => "<span class='ruby-func'>#{:end}</span>",
|
||||||
|
"fn" => "<span class='rust-fanc'>#{:fn}</span>",
|
||||||
|
"let" => "<span class='rust-fanc'>#{:let}</span>",
|
||||||
|
"mut" => "<span class='rust-fanc'>#{:mut}</span>",
|
||||||
|
"use" => "<span class='rust-fanc'>#{:use}</span>",
|
||||||
|
"String" => "<span class='rust-macro'>#{:String}</span>",
|
||||||
|
"println!" => "<span class='rust-macro'>#{:println!}</span>",
|
||||||
|
)
|
||||||
|
simple.gsub(/("[a-zA-Z0-9_ ,]+")/){ "<span class='contents'>#{$1}</span>" }
|
||||||
|
# "" => "<span class=''>#{:}</span>",
|
||||||
|
end
|
||||||
|
|
||||||
#テストで書きなぐった奴
|
#テストで書きなぐった奴
|
||||||
def html_escape(string)
|
def html_escape(string)
|
||||||
string.gsub(/['&\"<>\/]/, {
|
string.gsub(/['&\"<>\/]/, {
|
||||||
@ -280,7 +306,8 @@ class MDExtractor
|
|||||||
extractByHTMLTagName("br", false, true),
|
extractByHTMLTagName("br", false, true),
|
||||||
extractByHTMLTagName("a"),
|
extractByHTMLTagName("a"),
|
||||||
extractByHTMLTagName("img", false, true),
|
extractByHTMLTagName("img", false, true),
|
||||||
extractByHTMLTagName("s")
|
extractByHTMLTagName("s"),
|
||||||
|
extractByHTMLTagName("span")
|
||||||
].flatten.compact
|
].flatten.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user