User:Alien333/poemise

From Wikisource
Jump to navigation Jump to search

Documentation for poemise.js.

Puts lines < 3 characters at the end of the preceding line for punctuation, and lines starting by a lowercase for hard wrap.

Applies an indent pattern given with *[pattern].

In EBNF, and by growing priority:

pattern = ""
  | ( digit | "." | "[" any "]" ) pattern (* a digit means that many :'s, a "." a blank line and "[" any "]" is for something else at the beginning
  | "!" number                            (* multiple-digit indent *)
  | ( ";" | "'") number                   (* number*01;. or number*0;. *)
  | pattern "," pattern                   (* separating two sub-patterns *)
  | number "*" pattern                    (* pattern repeated number times *)
  | pattern ";" pattern;                  (* "," with higher priority *)

where

digit = 0-9
number = digit+

For example, 2*('4;!11);. <=> 2*('4,.!11) . <=> 2*(0 0 0 0 11) . <=> 0 0 0 0 11 0 0 0 0 11 .

Multiple-stanza patterns work, such as :3;'2 for 0 1 0 1 0 1 . 0 0 .

You can start at a specific index in your indent pattern with /[number].

The zone to be poemised is assumed to start at the beginning and to end at EOF.

The start can be put somewhere else with + and the end with -.

When an edge (start/end) is not limited, it will try to fill in with the * and the /.

For a last page of a poem, $ keeps it from adding an |end=.

+, -, $, *, /, parsed in that order, should be beginning of line (* and / absorb the whole line).

I am aware that my effort to compress this can lead to hard to read things, such as +$*2*56!10;'4, but eh, not going to be saved in page history.