File tree Expand file tree Collapse file tree 3 files changed +49
-36
lines changed
toc/summary_with_markdown_formatting/src Expand file tree Collapse file tree 3 files changed +49
-36
lines changed Original file line number Diff line number Diff line change @@ -106,39 +106,3 @@ fn example_book_can_build() {
106106
107107 md. build ( ) . unwrap ( ) ;
108108}
109-
110- /// Checks formatting of summary names with inline elements.
111- #[ test]
112- fn summary_with_markdown_formatting ( ) {
113- let temp = DummyBook :: new ( ) . build ( ) . unwrap ( ) ;
114- let mut cfg = Config :: default ( ) ;
115- cfg. set ( "book.src" , "summary-formatting" ) . unwrap ( ) ;
116- let md = MDBook :: load_with_config ( temp. path ( ) , cfg) . unwrap ( ) ;
117- md. build ( ) . unwrap ( ) ;
118-
119- let rendered_path = temp. path ( ) . join ( "book/toc.js" ) ;
120- assert_contains_strings (
121- rendered_path,
122- & [
123- r#"<a href="formatted-summary.html"><strong aria-hidden="true">1.</strong> Italic code *escape* `escape2`</a>"# ,
124- r#"<a href="soft.html"><strong aria-hidden="true">2.</strong> Soft line break</a>"# ,
125- r#"<a href="escaped-tag.html"><strong aria-hidden="true">3.</strong> <escaped tag></a>"# ,
126- ] ,
127- ) ;
128-
129- let generated_md = temp. path ( ) . join ( "summary-formatting/formatted-summary.md" ) ;
130- assert_eq ! (
131- fs:: read_to_string( generated_md) . unwrap( ) ,
132- "# Italic code *escape* `escape2`\n "
133- ) ;
134- let generated_md = temp. path ( ) . join ( "summary-formatting/soft.md" ) ;
135- assert_eq ! (
136- fs:: read_to_string( generated_md) . unwrap( ) ,
137- "# Soft line break\n "
138- ) ;
139- let generated_md = temp. path ( ) . join ( "summary-formatting/escaped-tag.md" ) ;
140- assert_eq ! (
141- fs:: read_to_string( generated_md) . unwrap( ) ,
142- "# <escaped tag>\n "
143- ) ;
144- }
Original file line number Diff line number Diff line change @@ -142,3 +142,46 @@ fn check_link_target_fallback() {
142142 TOC_TOP_LEVEL . len( ) + TOC_SECOND_LEVEL . len( )
143143 ) ;
144144}
145+
146+ // Checks formatting of summary names with inline elements.
147+ #[ test]
148+ fn summary_with_markdown_formatting ( ) {
149+ BookTest :: from_dir ( "toc/summary_with_markdown_formatting" )
150+ . check_toc_js ( str![ [ r#"
151+ <ol class="chapter">
152+ <li class="chapter-item expanded ">
153+ <a href="formatted-summary.html">
154+ <strong aria-hidden="true">1.</strong> Italic code *escape* `escape2`</a>
155+ </li>
156+ <li class="chapter-item expanded ">
157+ <a href="soft.html">
158+ <strong aria-hidden="true">2.</strong> Soft line break</a>
159+ </li>
160+ <li class="chapter-item expanded ">
161+ <a href="escaped-tag.html">
162+ <strong aria-hidden="true">3.</strong> <escaped tag></a>
163+ </li>
164+ </ol>
165+ "# ] ] )
166+ . check_file (
167+ "src/formatted-summary.md" ,
168+ str![ [ r#"
169+ # Italic code *escape* `escape2`
170+
171+ "# ] ] ,
172+ )
173+ . check_file (
174+ "src/soft.md" ,
175+ str![ [ r#"
176+ # Soft line break
177+
178+ "# ] ] ,
179+ )
180+ . check_file (
181+ "src/escaped-tag.md" ,
182+ str![ [ r#"
183+ # <escaped tag>
184+
185+ "# ] ] ,
186+ ) ;
187+ }
Original file line number Diff line number Diff line change 1+ # Summary formatting tests
2+
3+ - [ * Italic* ` code ` \* escape\* \` escape2\` ] ( formatted-summary.md )
4+ - [ Soft
5+ line break] ( soft.md )
6+ - [ \< escaped tag\> ] ( escaped-tag.md )
You can’t perform that action at this time.
0 commit comments