Bug 274289 - katepart: syntax engine unable to match empty line
Summary: katepart: syntax engine unable to match empty line
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: syntax (show other bugs)
Version: unspecified
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-27 17:18 UTC by Diggory Hardy
Modified: 2014-03-10 02:41 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Diggory Hardy 2011-05-27 17:18:06 UTC
Version:           unspecified (using KDE 4.6.2) 
OS:                Linux

In a katepart syntax highlighting file, I would expect to have some rule capable of matching empty lines. If I try the following:

<RegExpr String="^\s*$" attribute="common" context="#pop"/>

it only matches a line containing at least one space. I can't see any other rule which will match empty lines. Could this be fixed such that the above matches an empty line, please?

P.S. this is also mentioned in #243740.

Reproducible: Always
Comment 1 Russell 2011-11-23 05:06:10 UTC
Asciidoc, which allows users to create text files without complex formatting characters and then post-process them into many different formats (html, pdf, docbook), depends on blank lines to separate blocks and terminate formatting.

I've written an xml Kate highlighting file for asciidoc, but ran into this restriction.  

I would like to see some sort of notification of blank lines.

Reference: http://www.methods.co.nz/asciidoc/userguide.html
Comment 2 Russell 2011-12-16 21:25:53 UTC
Additional Information.

A blank line is a transition to a different context.

Simple Kate highlighting file:

<language name="RTest" section="Other" >
<highlighting>
<contexts>
  <context attribute="NormalStyle" lineEndContext="#stay" name="_NormalText">
    <RegExpr attribute="tstGreen" context="_Paragraph" String="^START" />
  </context>
  <context attribute="tstBlue" lineEndContext="#stay" name="_Paragraph">
    <RegExpr attribute="NormalStyle" context="#pop" String="^$" />
  </contexts> 

<itemDatas>
  <itemData name="NormalStyle" defStyleNum="dsNormal" />
  <itemData name="tstGreen"    defStyleNum="dsNormal" color="#00A800" />
  <itemData name="tstBlue"     defStyleNum="dsNormal" color="#0000FF" />
</itemDatas>
</highlighting>
</language>

Data example to go along with the above:

This is the first line of the file.
Look for START in column one.

START
This is a 1-line paragraph before a blank line.

This is a 2-line paragraph after a blank line.
Other formatting will occur within a paragraph.

This is a new paragraph. This is
  a line within the same paragraph but
  indented after the first line.

  This is a literal paragraph because it does
  not start in column 1.  Each paragraph should 
  start a new context.

START
Try again.

// <!-- kate: syntax RTest; space-indent on; indent-width 2; -->

Hope this helps.
Thank you.
Comment 3 zohn.joidberg 2012-08-23 09:48:02 UTC
I have a similar problem with the regex search&replace function in Kate. It has been bothering since KDE4 came out.
cf http://forum.kde.org/viewtopic.php?f=15&t=91394

My current workaround is using "\n\n" to match "^$" (not exactly the same, but works for replacing) or use vim...
Comment 4 Christoph Cullmann 2012-11-07 23:13:21 UTC
1. to search and replace: Just tried: search "^$" replace "MUH", works
2. for highlighting: true, empty lines are just skipped by the highlighting engine as all rules need at least one char to match (and no, end of line isn't counting). This can't be changed without regression many highlights, therefore you can now specify for each context an optional lineEmptyContext="..." where you tell to which context should be switched if a line with no content is found.

Git commit 48cd0f3fec6dcd8a3a59fb4125fd6cdf759d7acc by Christoph Cullmann.
Committed on 07/11/2012 at 23:50.
Pushed by cullmann into branch 'master'.

add lineEmptyContext to allow to specify what should happen if an empty line occurs

M  +2    -0    doc/kate/highlighting.docbook
M  +5    -0    kate/plugins/xmltools/language.dtd.xml
M  +2    -0    part/syntax/data/language.dtd
M  +148  -139  part/syntax/katehighlight.cpp
M  +7    -2    part/syntax/katehighlighthelpers.cpp
M  +6    -1    part/syntax/katehighlighthelpers.h

http://commits.kde.org/kate/48cd0f3fec6dcd8a3a59fb4125fd6cdf759d7acc
Comment 5 MountainX 2014-03-10 02:41:27 UTC
(In reply to comment #1)
> Asciidoc, which allows users to create text files without complex formatting
> characters and then post-process them into many different formats (html,
> pdf, docbook), depends on blank lines to separate blocks and terminate
> formatting.
> 
> I've written an xml Kate highlighting file for asciidoc, but ran into this
> restriction.  

Is your AsciiDoc highlighting file for Kate available to others (such as me)? Thanks