neurobin/mdx_include

Unintentional formatting of snippets

breakid opened this issue · 0 comments

While working on some project documentation, I wanted to include a particularly detailed docstring from a Python script. The slicing functionality worked well; however, since the entire snippet was indented in the original file, Markdown treated it as a code block and syntax highlight was automatically applied to it.

It would be nice to have the option to strip the smallest amount of white space on any line from every line. For instance:

    # This line is indented 4 spaces
    def function_name(self, arg1):
        # This line is indented 8 spaces
        print(arg1)

Would be normalized to:

# This line is indented 0 spaces
def function_name(self, arg1):
    # This line is indented 4 spaces
    print(arg1)

The function definition line had the least number of spaces (4), so four spaces were removed from all of the lines.

To match your existing formatting syntax, I recommend: {!< file_path_or_url!}

You could even use both (e.g., {!<> file_path_or_url!}) to unindent the included content then indent to match the destination.