EnlighterJS / Plugin.WordPress

:package: Official WordPress Plugin of EnlighterJS
http://wordpress.org/plugins/enlighter/
GNU General Public License v2.0
118 stars 17 forks source link

Generic Highlight - breakdown of tokens for colouring #292

Closed ajtruckle closed 4 years ago

ajtruckle commented 4 years ago

Hi

Here is some sample script where I use the Generic Highlighting:

PARAGRAPH "<div style="font-family: Calibri">
<div>
<h2><strong>Public Discourses CongregationName English group</strong></h2>
<hr>"
LOOP FROM "Home Talks" SORTBY "Last Given"
    TEXT "<p><strong style="background-color: #28456c; color: #ffffff"> "
    CUSTOMDATE_FIELD "Last Given" "%b %d, %Y"
    TEXT "  </strong>  "
    CONG_MEET_TIME "$LocalCong" "Last Given"
    TEXT " h. <br>"
    EOL
    TEXT "Theme: <strong>"
    TALK_THEME "Talk Number"
    TEXT " </strong> "
    TEXT "("
    FIELD "Talk Number"
    TEXT ") <br>"
    EOL
    TEXT "Speaker: <strong>"
    FIELD "Speaker"
    TEXT "</strong><br> "
    EOL
    TEXT "Congr.: <em> "
    FIELD "Congregation"
    TEXT "</em><br><br>"
    EOL
    TEXT "Chairman: <em>"
    FIELD "Chairman"
    TEXT " </em><br>"
    EOL
    TEXT "WT conductor: <em>"
    FIELD "Conductor"
    TEXT " </em><br>"
    EOL
    // Interpeter when visit of Circuit Overseer, field Miscellaneous is used for 2nd interpreter
    IF "Interpreter" ISNOT "$EmptyString"
        TEXT "Interpreter: <em>"
        FIELD "Interpreter"
        TEXT " </em><br>"
        EOL
    END_IF
    IF "Reader" ISNOT "-"
        TEXT "WT reader: <em>"
        FIELD "Reader"
        TEXT " </em><br>"
        EOL
    END_IF
    IF "Miscellaneous" ISNOT "$EmptyString"
        TEXT "2nd Interpreter: <em>"
        FIELD "Miscellaneous"
        TEXT " </em><br>"
        EOL
    END_IF
    // CLOSING PRAYER (field Miscellaneaous3)
    // No prayer when Misc3 = "-" , Speaker when Misc3= <NONE>
    IF "Miscellaneous3" ISNOT "-"
        TEXT "Closing prayer: <em>"
        IF "Miscellaneous3" ISNOT "$EmptyString"
            FIELD "Miscellaneous3"
        END_IF
        IF "Miscellaneous3" IS "$EmptyString"
            FIELD "Speaker"
        END_IF
        TEXT " </em><br>"
    END_IF
    EOL
    // additional tasks for ZOOM
    // Only shown when Video Conference Host is filled, Misc2 is used for Mute/Unmute
    IF "Video Conference Host" ISNOT "$EmptyString"
        TEXT "<ul>"
        TEXT "<li>Host/Attendent: <em>"
        FIELD "Video Conference Host"
        TEXT " </em></li>"
        EOL
        TEXT "<li>Audio/Video: <em>"
        FIELD "Video Conference CoHost"
        TEXT " </em></li>"
        EOL
        TEXT "<li>Mute/Unmute: <em>"
        FIELD "Miscellaneous2"
        TEXT " </em></li></ul>"
        EOL
    END_IF
    TEXT "</p><hr>"
    EOL
END_LOOP
PARAGRAPH "</div></div>"
ENDPAGE

I noticed this bit towards the top:

Colours

How does it decide to break these bits I highlighted? I thought it might have broken that down into tokens? Just curious.

Thanks.

AndiDittrich commented 4 years ago

a detailed explanation is going to be complex

  1. every regex rule is applied to the code (to match every possible sequence using overlapping matches)
  2. the results are ordered by their absolute index
  3. overlapping elements are dropped

in your case the quotes are invalid in most programming languages

ajtruckle commented 4 years ago

in your case the quotes are invalid in most programming languages

I get where you are coming from and now I see why it may colour odd because of that. Understood. Thanks!