Indent action convert font to courier

Hello,
The indent action converts font to courier.
What should I modify in the script ?
thanks very much for your time and help
—-
image
—-
// character string used for indent
let indent = " ";
if (draft.languageGrammar == “Taskpaper”) {
indent = “\t”;
}

// grab ranges and text
let [selStart, selLen] = editor.getSelectedRange();
let [lnStart, lnLen] = editor.getSelectedLineRange();
let lnText = editor.getTextInRange(lnStart, lnLen);

// loop over lines and add indents skipping blank lines
let indentedLines = ;
let indentCt = 0;
let fl = false;
if (lnText.endsWith(“\n”)) {
lnText = lnText.slice(0, -1);
fl = true;
}
let lines = lnText.split(“\n”);
for(let line of lines) {
if (line.length > 0) {
indentedLines.push(indent + line);
indentCt++;
}
else {
indentedLines.push(line);
}
}

// set text
let resultText = indentedLines.join(“\n”);
if (fl) { resultText = resultText + “\n”; }
editor.setTextInRange(lnStart, lnLen, resultText);

// update selection
let newStart = selStart + indent.length;
let newLen = selLen + (indent.length * (indentCt - 1))
editor.setSelectedRange(newStart, newLen);

Is your format taskpaper by any chance? If so, you probably want to review the file format and consider what each line would be interpreted as - project, task, or note.

https://guide.taskpaper.com/getting-started/

1 Like

thank you for your reply.
I don‘t know taskpaper, and just downloaded the action from the actions list. I think that it‘s one of Greg‘s action and was hoping that he would provide a quick solution. I don‘t want to start learning taskpaper.
thank you for the reference.

Taskpaper is intentionally a very simple format. It has projects, tasks, notes and tags. I think that’s it. Only takes 2 minutes to learn.

Example of Taskpaper from https://github.com/davidoc/taskpaper.vim/blob/master/doc/example.taskpaper

Example Project:
	- Start example project file @computer @done
	- Brainstorm project with colleagues @work
	- Email Joan about project @email
	Sub Project:
		- Sub task

Next Project:
	- Draft ideas for next project @anywhere
	- Email Bob to arrange meeting @email
1 Like

thank you for your reply.
I‘m sorry: I am confused.
I am in Drafts and only in Drafts. I am working with lists, using the indent, outdent, move line up and down actions.
My question is only about drafts.
I notice that if I create a bulleted list, and use the indent action in Drafts and only in Drafts, my font changes in Drafts.
thanks again for your help and time

You didn’t answer this explicitly earlier. My guess is not, but that you are using Taskpaper syntax.

Let’s look at the example above when displayed in Taskpaper format.

Now let’s look at the same example but with the Draft set as Markdown rather than Taskpaper.

Note the sub project entry.

Now take a look at code blocks in the Markdown specification.

And now, if my initial assumption is correct, you should understand what is going on.

1 Like

How I understand ! thanks VERY much !

I had not seen in the documentation that if I start a bulleted list with * I get a markdown list. If I start a list with . I get a taskpaper type list (judged by the format of the indent)
thanks again

I want to ask you a question but I am concerned about irritating you. I thought about it and decided to ask it anyways.
When I am in drafts markdown, I can create identical looking bulleted lists with lines starting . and with *
In the different preview mode however those lines starting with* look like lists on separate lines with indents whereas those lines starting with . do not. Text is continues without line breaks
Thank you for your patience!

Technically you still haven’t asked a question. You have made some statements. But one of the statements is false.

If you start a set of lines with a period (“.”), this will not look the same as a set of lines with an asterisk (“-”); but as you observed the result in converted Markdown is entirely different. This is exactly as it should be.

Your use of periods to initiate lines is not a Markdown syntax option. You can fake it a little by putting in line breaks, but it is simply something that has no special syntactic meaning in Markdown.

You can use asterisks, hyphens and pluses to create lists and these are interchangeable. Periods are just periods.

My suspicion is that your confusion comes from how Drafts itself behaves when you start a line with a period followed by a space. When you add a newline, Drafts automatically inserts a period and space at the start of the next line, and so on. It doesn’t do this for all symbols, just a handful with a period being one of them.

I’ve no insight as to why it does this, but it still stands that a period is not a Markdown list identifier.

1 Like

I can’t thank you enough. You cleared up a lot of confusion in my mind. Who knows where I got the idea that lists start with periods.
I am very grateful for your help and all the time you took to detail and illustrate your reply.