File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ # Code from http://movb.de/jekyll-details-support.html
2+
3+ module Jekyll
4+ module Tags
5+ class DetailsTag < Liquid ::Block
6+
7+ def initialize ( tag_name , markup , tokens )
8+ super
9+ @caption = markup
10+ end
11+
12+ def render ( context )
13+ site = context . registers [ :site ]
14+ converter = site . find_converter_instance ( ::Jekyll ::Converters ::Markdown )
15+ caption = converter . convert ( @caption ) . gsub ( /<\/ ?p[^>]*>/ , '' ) . chomp
16+ body = converter . convert ( super ( context ) )
17+ "<details><summary>#{ caption } </summary>#{ body } </details>"
18+ end
19+
20+ end
21+ end
22+ end
23+
24+ Liquid ::Template . register_tag ( 'details' , Jekyll ::Tags ::DetailsTag )
Original file line number Diff line number Diff line change @@ -156,6 +156,16 @@ fig.write_html('assets/plotly/demo.html')
156156
157157***
158158
159+ ## Details boxes
160+
161+ Details boxes are collapsible boxes which hide additional information from the user. They can be added with the ` details ` liquid tag:
162+
163+ {% details Click here to know more %}
164+ Additional details, where math $$ 2x - 1 $$ and ` code ` is rendered correctly.
165+ {% enddetails %}
166+
167+ ***
168+
159169## Layouts
160170
161171The main text column is referred to as the body.
Original file line number Diff line number Diff line change @@ -35,6 +35,28 @@ d-article {
3535 display : inline ;
3636 }
3737
38+ // Style taken from code blocks
39+ details {
40+ color : var (--global-text-color );
41+ background-color : var (--global-code-bg-color );
42+ margin-top : 0 ;
43+ padding : 8px 12px ;
44+ position : relative ;
45+ border-radius : 6px ;
46+ display : block ;
47+ margin-bottom : 20px ;
48+ grid-column : text ;
49+ overflow : auto ;
50+ max-width : 100% ;
51+ summary {
52+ color : var (--global-theme-color );
53+ }
54+ p {
55+ margin-top : 0.5rem ;
56+ margin-bottom : 0.5rem ;
57+ }
58+ }
59+
3860 d-contents {
3961 align-self : start ;
4062 grid-column : 1 / 4 ;
You can’t perform that action at this time.
0 commit comments