Chandrew Chandrew - 1 month ago 11
Markdown Question

Pasting HTML or Markdown lists preserving indentation

I need a way to paste Markdown or Google Docs content that is in a list and have the content come out as indented text.

I don't care whether it's an ordered list or unordered list, and I don't care if I'm pasting it into plain text or a spreadsheet. I don't even care if the underlying content is in Markdown or HTML. I just want a way to copy indented lists that were created in a WYSIWYG editor and paste them into something that retains the indentation without bringing over the underlying HTML or Markdown or whatever runs the WYSIWYG system.

Example: say I have this list.

<ol>
<li>Main Heading
<ul>
<li>List item 1</li>
<li>List item 2</li>
</ul>
<li>Secondary Heading
<ul>
<li>List item 1</li>
<li>List item 2</li>
</ul>
</ol>


It appears as:


  1. Main Heading


    • List item 1

    • List item 2


  2. Secondary Heading


    • List item 1

    • List item 2




I want to be able to select the list, copy it with Command+C, and paste it into either (a) a spreadsheet where the destination column represents the level of indentation, so that column A is unindented, column B is indented one level, etc., or (b) a plain text document where the indentation is represented as tabs or spaces.

Answer

The problem is with HTML. HTML does not include any text formatting, it is plain text which has been styled with CSS. Even if you did not write the CSS for the list yourself, it is still styled with CSS using the default CSS properties for the element.

Styling and formatting are completely different, when you copy and paste some text, you are copying the text and the formatting, the CSS styling will be ignored.