amend blag post about optimizing PDFs (added convert -page A4)
[www-rohieb-name.git] / projects / pdf.lang
1 -- vim: set ft=lua ts=2 sw=2 et :
2 -- Language definition for PDF files
3 -- Author: Roland Hieber <rohieb@rohieb.name>
4 -- Date: 2013-11-22
5 -- Known Bugs:
6 -- * Does not highlight files with MacOS (CR-only) line endings
7 -- * Does not (yet) highlight inside streams due to limitations in the library
8 --
9
10 Description="Highlighting definitions for the Portable Document Format (PDF)"
11
12 IgnoreCase=false
13
14 -- File Structure
15 PreProcessor={
16 Prefix=[[%PDF-[0-9]\.[0-9]|%%EOF|xref|startxref|trailer]]
17 }
18
19 -- Comments. But do not match file structure elements.
20 Comments={
21 { Block=false,
22 Delimiter={ [[%(?!PDF-[0-9]\.[0-9]|%EOF)]] },
23 },
24 }
25
26 -- Numbers: 0.45, +1.34, -.4, 123, 4., and so on.
27 Digits=[[ [-+]?\.[0-9]+|[-+]?[0-9]+\.?[0-9]* ]]
28
29 -- Strings: (string), <hex> and streams
30 Strings={
31 DelimiterPairs= {
32 { Open=[[ \( ]], Close=[[ \) ]] },
33 { Open=[[ < ]], Close=[[ > ]] },
34 { Open=[[ ^stream ]], Close=[[ ^endstream ]], Raw=true },
35 }
36 }
37
38 -- Note: we highlight dictionary and array syntax as "keywords", so we have to
39 -- include them in Identifiers. This definition basically matches the allowed
40 -- characters for Names. Also, we do not want to match Numbers, Streams,
41 -- References and file structure elements as identifiers
42 Identifiers=[[ (?!%PDF-[0-9]\.[0-9]|%%EOF|xref|startxref|trailer|[0-9]+\s+[0-9]+\s+(R|obj)|[-+]?\.[0-9]+|[-+]?[0-9]+\.?[0-9]*)[^\s\[\]\(\){}<>/%]+ ]]
43
44 Keywords={
45 -- Indirect Objects
46 { Id=1,
47 Regex=[[ [0-9]+\s+[0-9]+\s+(obj|R)|endobj]],
48 Group=0
49 },
50 -- Arrays and Dictionaries
51 { Id=2,
52 Regex=[[ \[|\]|<<|>> ]],
53 },
54 -- Names
55 { Id=3,
56 Regex=[[ /[^\s\[\]\(\){}<>/%]+ ]],
57 },
58 -- Constants
59 { Id=4,
60 --List={"true", "false", "null"},
61 Regex=[[ true|false|null ]],
62 },
63 }
This page took 0.044043 seconds and 5 git commands to generate.