This commit is contained in:
@@ -92,6 +92,7 @@ body {
|
||||
font: 13.34px $font-default;
|
||||
font-size: small;
|
||||
line-height: 1.4;
|
||||
counter-reset: h1;
|
||||
}
|
||||
|
||||
img {
|
||||
@@ -117,6 +118,22 @@ a {
|
||||
|
||||
/* Markdown body */
|
||||
|
||||
.header-enum {
|
||||
h2 {counter-reset: h3}
|
||||
h3 {counter-reset: h4}
|
||||
h4 {counter-reset: h5}
|
||||
h5 {counter-reset: h6}
|
||||
|
||||
--header-enum-style: decimal;
|
||||
|
||||
h1:before {counter-increment: h1; content: counter(h1, var(--header-enum-style)) ". ";}
|
||||
h2:before {counter-increment: h2; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) ". ";}
|
||||
h3:before {counter-increment: h3; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) "." counter(h3, var(--header-enum-style)) ". ";}
|
||||
h4:before {counter-increment: h4; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) "." counter(h3, var(--header-enum-style)) "." counter(h4, var(--header-enum-style)) ". ";}
|
||||
h5:before {counter-increment: h5; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) "." counter(h3, var(--header-enum-style)) "." counter(h4, var(--header-enum-style)) "." counter(h5, var(--header-enum-style)) ". ";}
|
||||
h6:before {counter-increment: h6; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) "." counter(h3, var(--header-enum-style)) "." counter(h4, var(--header-enum-style)) "." counter(h5, var(--header-enum-style)) "." counter(h6, var(--header-enum-style)) ". ";}
|
||||
}
|
||||
|
||||
.markdown-body {
|
||||
padding: 1em;
|
||||
font-size: 15px;
|
||||
|
||||
@@ -66,7 +66,7 @@ Mousetrap.bind(['e'], function( e ) {
|
||||
</div>
|
||||
</div>
|
||||
{{/has_header}}
|
||||
<div class="markdown-body">
|
||||
<div class="markdown-body {{#header_enum?}}header-enum{{/header_enum?}}" {{#header_enum?}}style="--header-enum-style:{{header_enum_style}};"{{/header_enum?}}>
|
||||
{{{rendered_metadata}}}
|
||||
{{{content}}}
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,14 @@ module Precious
|
||||
include HasPage
|
||||
|
||||
attr_reader :content, :page, :header, :footer
|
||||
|
||||
VALID_COUNTER_STYLES = ['decimal', 'decimal-leading-zero', 'arabic-indic', 'armenian', 'upper-armenian',
|
||||
'lower-armenian', 'bengali', 'cambodian', 'khmer', 'cjk-decimal', 'devanagari', 'georgian', 'gujarati', 'gurmukhi',
|
||||
'hebrew', 'kannada', 'lao', 'malayalam', 'mongolian', 'myanmar', 'oriya', 'persian', 'lower-roman', 'upper-roman',
|
||||
'tamil', 'telugu', 'thai', 'tibetan', 'lower-alpha', 'lower-latin', 'upper-alpha', 'upper-latin', 'cjk-earthly-branch',
|
||||
'cjk-heavenly-stem', 'lower-greek', 'hiragana', 'hiragana-iroha', 'katakana', 'katakana-iroha', 'disc', 'circle', 'square',
|
||||
'disclosure-open', 'disclosure-closed'] # https://www.w3.org/TR/css-counter-styles-3/
|
||||
|
||||
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
||||
DEFAULT_AUTHOR = 'you'
|
||||
@@to_xml = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' }
|
||||
@@ -147,6 +155,16 @@ module Precious
|
||||
@rendered_metadata ||= table(metadata)
|
||||
end
|
||||
|
||||
def header_enum?
|
||||
!!metadata['header_enum']
|
||||
end
|
||||
|
||||
def header_enum_style
|
||||
if header_enum?
|
||||
VALID_COUNTER_STYLES.include?(metadata['header_enum']) ? metadata['header_enum'] : 'decimal'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Wraps page formatted data to Nokogiri::HTML document.
|
||||
|
||||
Reference in New Issue
Block a user