tajmone / ST4-Asciidoctor

AsciiDoc Package for SublimeText 4
https://tajmone.github.io/ST4-Asciidoctor
MIT License
11 stars 6 forks source link

Smart Code Block Converter Command #11

Open polyglot-jones opened 3 years ago

polyglot-jones commented 3 years ago

I plan to write a command where you select one or more lines and then invoke the command to have it interpret the content and transform it into an AsciiDoc block.

Use Case 1: quotations

If every line follows the pattern of: text enclosed in double-quotes (or typographical ones) immediately followed by an em-dash, double n-dashes, or a tilde, followed by anything that begins with a letter, then each line is converted into a quotation block.

"The cure for boredom is curiosity. There is no cure for curiosity." -- Dorothy Parker

becomes

[quote,Dorothy Parker]
__________________________________________
The cure for boredom is curiosity. There is no cure for curiosity.
__________________________________________

Use Case 2: Comment Blocks

// a whole

// bunch
// of comments

becomes

////
a whole

bunch
of comments
////

Use Case 3: source code

If it can determine that the selected lines are some sort of source code, then it'll enclose it as a source code block.

[source, bash]
-------------------------------------------------------------------------------
sudo apt update
-------------------------------------------------------------------------------

In all cases, it would unindent the block if every line begins with white space.