question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto-Correcting Markup

See original GitHub issue

I’m loving this tool, but had a quick question about the output.

I have:

<ul>
    <li>a list item <li>with a weirdly nested list item</li> and more text afterwards</li>
</ul>

Which renders to:

<ul>
    <li>a list item </li>
    <li>with a weirdly nested list item</li> and more text afterwards
</ul>

I’m trying to catch poorly structured markup like this using $(“li > li”).addClass(“attn”) so that it can be reviewed and fixed manually. Unfortunately, this auto-correction actually obscures the error and makes it harder to find.

Is this intentional behaviour?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sholladaycommented, Nov 10, 2017

Hi @wahengchang if you are experiencing some kind of problem, it looks like a different issue.

Whereas the OP was hoping for a way to turn off Cheerio’s “auto-fixing” behavior that corrects invalid markup, your markup is already perfectly valid - I double checked by reading the spec and trying it in the W3C validator, just to be sure.

What problem are you having exactly? You should probably open a new issue for it, since this one is closed and therefor won’t receive much attention.

1reaction
MCTaylor17commented, Oct 27, 2014

I understand I’m not the typical user. There probably aren’t many people using this for updating static HTML files from an LMS to comply with a11y.

This just struck me as a potential issue due to the loss of fidelity. There seems to be quite a bit of confusion surrounding nested lists, for instance, some people can’t decide between this:

<ul>
    <li>Level 1
        <ul>
            <li>Level 2</li>
        </ul>
    </li>
</ul>

this,

<ul>
    <li>Level 1
        <li>Level 2</li>
    </li>
</ul>

or this.

<ul>
    <li>Level 1</li>
    <ul>
        <li>Level 2</li>
    </ul>
</ul>

This type of error is common when Word docs are converted to HTML. Another similar issue with Word docs is stuff that looks like this:

<ul>
    <li>Level 1
        <ul>
            <li>
                <ul>
                    <li>
                        <ol>
                            <li>Styled for looks</li>
                            <li>Rather than content</li>
                        </ol>
                    </li>
                </ul>
            </li>
        </ul>
    <li>Level 1</li>
    <li>Level 1</li>
    </li>
</ul>

The nature of my work is finding and fixing markup. Reality is, garbage in, garbage out is all part of the job. A manual inspection is required regardless, so for me it’s not it’s not the biggest deal.

Overall, I’m quite happy with the utility of Cheerio and think it’s a great tool for the job!

Cheers,

Mike

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formatting Autocorrect Entries - Legal Office Guru
My advice is to select the text using your keyboard. Place your cursor before the first character, press and hold the Shift key,...
Read more >
How to Use Autocorrect in Google Docs - Zapier
Google Docs offers an autocorrect feature: It's called Automatic ... Fix common misspellings, add markup, or create a text expander.
Read more >
MICROSOFT WORD AUTO CORRECT AUTO FORMAT
Microsoft Word Tips, Tricks and Shortcuts Video Series!All steps have been tested in Word 2007, 2010, 2013 and 2016.
Read more >
Auto Correct Auto Text - YouTube
We make legal formatting in MS Word easy to do for lawyers, legal secretaries, and paralegals. Through Kwik Docs, our legal macro package, ......
Read more >
How to Use Microsoft Word AutoCorrect - ProofreadingPal
AutoFormat applies a predetermined set of formatting changes to an already-completed document with the click of single button, which is helpful ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found