[Geany] Making HTML from plain text; joining lines

Ross McKay rosko at xxxxx
Mon Mar 30 22:31:14 UTC 2009


Vlastimil Ott wrote:

>I'm editing some plain text. It's a article and it will be published on web in 
>HTML. How could I add paired tags to a paragraph? The only way I know is 
>
>1. go to paragraph begin, write <p>
>2. delete </p> (autoclosing)
>3. go to paragraph end
>4. write (or copy) </p>
>
>I've used Quanta with user-defined hotkeys for years. They helped a lot - Ctrl-; 
>for applying <p></p> to a selection, Ctrl-1 for pasting <h1></h1> and so on.

For stuff that you do regularly, you can write a simple script (shell /
python / your favourite scripting language) that does the job for
standard input, and set it as a Custom Command:

	Edit > Format > Send Selection To > Set Custom Command

The first three have hotkeys.

I did this for a few common things, but I hardly use that any more
because I find that knowing how to do regular expression search and
replace is more flexible (but I still have scripts for stuff like
URL-encoding).

To wrap a selection with <p>...</p> you can do this in regex search/
replace:

Search for: (.*)
Replace with: <p>\1</p>
Use regular expressions: ticked

If you select a piece of text within a line and click the In Selection
button, just that piece is wrapped with <p>...</p>. If you select a
bunch of lines, each line is wrapped with <p>...</p>.

You might want to mix the Set Custom Command method with the regex
search and replace method.

>How to join lines with hard breaks (in fact paragraphs)?

Yeah, also awaiting an answer to that one...
-- 
Ross McKay, Toronto, NSW Australia
"Let the laddie play wi the knife - he'll learn"
- The Wee Book of Calvin



More information about the Users mailing list