MarkBind / markbind

MarkBind is a tool for generating content-heavy websites from source files in Markdown format
https://markbind.org/
MIT License
135 stars 124 forks source link

Tabs doesn't work in one place #352

Open damithc opened 6 years ago

damithc commented 6 years ago

v1.9.0

I can't figure out why tabs don't work in this particular instance: https://nus-cs2103.github.io/website-base/se-book-adapted/chapters/oop.html#overloading image

Source: https://github.com/se-edu/se-book/blob/master/oop/inheritance/overloading/text.md

Problem: Content of the Python tab appears no-matter which tab is selected. It seems to be connected to the content of the Java tab. If I delete its content, the tabs work.

yamgent commented 6 years ago

Removing the extra blank lines seems to fix the problem:

diff --git a/oop/inheritance/overloading/text.md b/oop/inheritance/overloading/text.md
index 132cc1c4..36707997 100644
--- a/oop/inheritance/overloading/text.md
+++ b/oop/inheritance/overloading/text.md
@@ -34,14 +34,10 @@ An operation can be overloaded inside the same class or in sub/super classes.

 <tabs>
   <tab header="Java">
-
-<include src="text-java.fr" />
-
+    <include src="text-java.fr" />
   </tab>
   <tab header="Python">
-
-<include src="text-python.fr" />
-
+    <include src="text-python.fr" />
   </tab>
 </tabs>
yamgent commented 6 years ago

Having the extra blank lines will affect ultimately how the content gets generated. This is compliant with the CommonMark specification regarding HTML blocks.

If we observe the generated html of the original version vs. the fixed version (oop_generated.zip), we can see that that is indeed the case.

diff --git a/oop_original.html b/oop_fixed.html
index a8cc8e0..83ecc8e 100755
--- a/oop_original.html
+++ b/oop_fixed.html

@@ -2441,19 +2429,15 @@ Ben is a student
                                 </tip-box>
                                 <p><span class="fas fa-paperclip"></span> Resources:</p>
                                 <ul>
-                                  <li>
-                                    <p><a href="https://www.javatpoint.com/method-overloading-in-java"><strong>Method Overloading in Java</strong></a> a tutorial from <a href="http://javapoint.com">javapoint.com</a>. Also mentions the topic of a related
-                                      topic <mark><em>type promotion</em></mark>.</p>
-                                  </li>
+                                  <li><a href="https://www.javatpoint.com/method-overloading-in-java"><strong>Method Overloading in Java</strong></a> a tutorial from <a href="http://javapoint.com">javapoint.com</a>. Also mentions the topic of a related topic
+                                    <mark><em>type promotion</em></mark>.</li>
                                 </ul>
                               </div>
                             </tab>
-
-
-                            <p>
-                              <tab header="Python"></tab>
-                            </p>
-                            <div><span>❗️ Python does not have direct support for method overloading.</span></div>
+                          
+                            <tab header="Python">
+                              <div><span>❗️ Python does not have direct support for method overloading.</span></div>
+                            </tab>
                           </tabs>
                           <p></p>
                         </div>
damithc commented 6 years ago

I see. Good catch. Markbind parser uses blank lines to identify start of markbind text. Sometimes not having a blank line (e.g., if there is no blank line before <tip-box>) can cause the parser to not interpret code as markbind. That's why I got used to adding blank lines liberally.

How do we explain to the user where to not use blank lines? Intuitively, I can't think of anything wrong with having a blank line there.

acjh commented 6 years ago

Now that we have <markdown> and <md>, we should no longer tell users to use blank lines.

Agreed that it's difficult to explain.

damithc commented 6 years ago

May be internally trim extra line breaks that appear around a <tab> tag?