Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Code Block Converter Command #11

Open
polyglot-jones opened this issue Jul 23, 2021 · 0 comments
Open

Smart Code Block Converter Command #11

polyglot-jones opened this issue Jul 23, 2021 · 0 comments
Labels
⚙️ commands Package Feature: Commands

Comments

@polyglot-jones
Copy link
Collaborator

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
-------------------------------------------------------------------------------
  • If there is a she-bang to go by (#!/usr/bin/env bash), it's obvious.
  • If there are lines that start with sudo then it's a bash script.
  • If there are lines that start with import or from ... import then it's Python.
  • etc.

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

@tajmone tajmone added the ⚙️ commands Package Feature: Commands label Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️ commands Package Feature: Commands
Projects
None yet
Development

No branches or pull requests

2 participants