Blog

JavaFX Codeeditors - New features for Scanner rules (required to support eg Asciidoc)

Yesterday I worked on a cool addition required to develop syntax highlighting for things like Asciidoc. screen-with-preview Suppose you want to define lexical highlighting for Asciidoc you very likely have a rule like this:

lexical_highlighting {
  // ...
  rule __dftl_partition_content_type whitespace javawhitespace {
    // ...
    adoc_section_0 {
      single_line "= "
    }
    // ...
  }
  // ...
}

But now suppose your asciidoc-File looks like this:

= This is a head line
if a = b you're doing something wrong

the above rule would produce the following highlighting ascii-wrong which obivously is wrong. What our rule really has to express is

if a line starts with = (equal-sign) followed by a space

So the new addition I added the the ldef-DSL is that you can now define at which column in a line the rule has to start

lexical_highlighting {
  // ...
  rule __dftl_partition_content_type whitespace javawhitespace {
    // ...
    adoc_section_0 {
      single_line "= " col eq 0
    }
    // ...
  }
  // ...
}

and now the result looks ok ascii-correct

published on
Previous
Major improvements to @Preference in e(fx)clipse 2.2.0