I'm trying to fix a table of contents with the following code and am am getting this error:

"Error at line 20 at column 8: Opening and ending tag mismatch li line 0 and html"

This is confusing because the closing tag for li is , not html. And all the

  • tags are closed. Also, in an ebook, you don't simply have html file where there is a line 20.

    Here's the code:

    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <html xmlns="http://www.w3.org/1999/xhtml"  
        <meta content="text/html; charset=utf-8" http-equiv="Content-  Type"/>
    <link href="../Styles/stylesheet.css" rel="stylesheet" type="text/css"/>
    <link href="../Styles/page_styles.css" rel="stylesheet"    type="text/css"/>
      <body class="calibre">
        <h1 class="calibre1">Contents</h1>
        <ul class="calibre2" id="toc-style"><li class="calibre3">
        <li><a class="calibre4" href="../Text/Flow_0_split_000.xhtml">Foreword/The Art of Correction</a></li>
        <li><a class="calibre4" href="../Text/Flow_0_split_001.xhtml">The Revelation of Anakum</a></li>
        <li><a class="calibre4" href="../Text/Flow_0_split_002.xhtml">Justice is Blind</a></li>
  • 12
    • What kind of tools are you using to edit your ebook?
      – Sekhemty
      May 20 '17 at 10:39
    • Quark export to ePub, ePub import to Calibre, Calibre convert to ePub (for line spacing and cover), Sigil for ToC tweaking.
      – user26732
      May 21 '17 at 5:31
    • Calibre can automatically create a ToC for you, instead of having to edit its code manually; as others have pointed out, it is not correctly coded. Besides that, you might want to try to use just a program (Calibre editor or Sigil) instead of all these passages and conversions.
      – Sekhemty
      May 21 '17 at 13:50
    • I tried. Calibre treated a single footnote as a chapter and didn't recognize the other chapters. Nor would it let me correct or remove an existing ToC that was generated by another program that didn't let me edit the ToC either. That's why I had to break out Sigil in the first place. Now I have a nicely formatted iBooks Author project that apparently cannot be exported to ePub. Arrrgh. And yes, I used their template.
      – user26732
      May 21 '17 at 14:22
    • If you use <h1> ... <h6> html headers for chapter titles only, and select the option to create entries for main headers, it will work. Having just a footnote recognized as a main entry sounds like your files are not coded with clean and proper html. A program can't interpret your intentions, giving it proper code is a responsibility of yours.
      – Sekhemty
      May 21 '17 at 14:39

    The problem is that you have an open UL tag with no close tag. (and an extra body tag in strange place). Did you paste the code correctly into the Stack Exchange form?

    You might want to consider pasting the contents into the calibre editor or sigil editor and beginning from scratch. Or pasting it into word, removing all formatting except headings and using calibre to convert from MS Word to epub. Typically calibre generates the tocs from MS word pretty well.

    • I don't see any <ul> tags in the above example. There's an <ol> tag which is closed. There's a ul class definition but no tag. Where do you see a tag?
      – user26732
      May 21 '17 at 5:30
    • 1
      @user26732 Of course there is a UL tag it starts with <ul and has a class attribute calibre2. You may want to use this xhtml validator by w3c.org to find errors in your source (it indicates four of them), as you don't seem to be too familiar with valid XHTML syntax (and terminology).
      – Anthon
      May 21 '17 at 11:23
    • Agreed. I would be much happier with plain old html, but that's not what the tools are throwing at me.
      – user26732
      May 21 '17 at 14:19

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

    Not the answer you're looking for? Browse other questions tagged or ask your own question.