-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix overzealous heredoc highlighting
As the example Sudoku program demonstrates, the behaviour of heredocs in GNU APL isn't synonymous with those of other languages. If used inside a function, the heredoc won't start to collect lines until the function is called - at which point, it begins collecting whatever's under the call. Although this is useful, it also makes it impossible for a heredoc to be used in a function without screwing the document's highlighting. Instead of removing heredoc formatting altogether, this commit allows authors to "opt-in" based on whether the terminator contains the language's name: text ← ⎕INP "END-OF-HTML" <h1> Heading </h1> <a href="somewhere.htm"> Link </a> END-OF-HTML Only a handful of languages are recognised in this way: anything else is regarded as APL code. Authors can enable highlighting for the following: ╔══════════════╦═══════════════════════════════════════════════╗ ║ Language ║ Activated by ║ ╟──────────────╫───────────────────────────────────────────────╢ ║ HTML ║ HTML, HTM ║ ║ XML ║ XML, XSLT, SVG, RSS ║ ║ CSS ║ CSS, Stylesheet ║ ║ JavaScript ║ JS, ECMAScript, JavaScript, JScript ║ ║ JSON ║ JSON ║ ║ Plain text ║ Raw Text, Plain Text, Raw, Plain ║ ╚══════════════╩═══════════════════════════════════════════════╝ The matching is performed case-insensitively, and will also work against substrings in addition to complete matches (raw text is the exception): text ← ⎕INP "HTML" text ← ⎕INP "EndHTMLDocument" text ← ⎕INP "CSS" In addition to these changes, a few pattern-matching bugs were fixed: * Heredocs needed leading whitespace before they would highlight * The closing line was expected to have no other characters except the terminating string (whitespace included). GNU APL actually places no such restriction, though it discards anything sharing the terminator sequence's line.
- Loading branch information
Showing
4 changed files
with
172 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
⍝ HTML | ||
text ← ⎕INP "END-OF-HTML" | ||
<header id="top"> | ||
Heading | ||
</header> | ||
END-OF-HTML | ||
|
||
|
||
aaa text ← ⎕INP "END-OF-XHTML" | ||
<div id="top"> | ||
Heading | ||
</div> | ||
END-OF-XHTML | ||
|
||
|
||
|
||
aatext ← ⎕INP "END-OF-HTML" | ||
<header id="top">Heading</header> | ||
========== END-OF-HTML =============== | ||
|
||
|
||
|
||
|
||
|
||
⍝ XML | ||
tree ← ⎕INP "END-OF-XML" | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<svg><!-- Fancy lines, etc --></svg> | ||
END-OF-XML | ||
|
||
svg ← ⎕INP "SVG" | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<svg><!-- Fancy lines, etc --></svg> | ||
End of SVG | ||
|
||
|
||
|
||
⍝ JavaScript | ||
js ← ⎕INP "ENDJS" | ||
"use strict"; | ||
let light = "shine"; | ||
function fn(){ | ||
return Math.max(...[5, 6, 8]); | ||
} | ||
JSON.stringify({}); | ||
const $ = s => document.querySelector(s); | ||
ENDJS | ||
|
||
|
||
⍝ JSON | ||
json ← ⎕INP "JSON" | ||
{ | ||
"name": "language-apl", | ||
"version": "0.0.1", | ||
"description": "APL language support for Atom", | ||
"keywords": ["APL", "Dyalog"], | ||
"repository": "https://github.com/Alhadis/language-apl", | ||
"license": "ISC", | ||
"engines": { | ||
"atom": "*" | ||
}, | ||
"dependencies": {} | ||
} | ||
JSON | ||
|
||
|
||
⍝ CSS | ||
styles ← ⎕INP "END-CSS" | ||
html{ | ||
background: #f00; | ||
} | ||
END-CSS | ||
|
||
|
||
|
||
⍝ Plain text | ||
text ← ⎕INP "Plain Text" | ||
Z←Z←81 9⍴1 ◊ F1←0 | ||
Plain Text |