-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfendo.markup.fendo.language.fs
124 lines (94 loc) · 3.7 KB
/
fendo.markup.fendo.language.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
.( fendo.markup.fendo.language.fs ) cr
\ This file is part of Fendo
\ (http://programandala.net/en.program.fendo.html).
\ This file defines the Fendo markup for languages.
\ Last modified 20210429T1659+0200.
\ See change log at the end of the file.
\ Copyright (C) 2013,2014,2017,2018,2021 Marcos Cruz (programandala.net)
\ Fendo is free software; you can redistribute
\ it and/or modify it under the terms of the GNU General
\ Public License as published by the Free Software
\ Foundation; either version 2 of the License, or (at your
\ option) any later version.
\ Fendo is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied
\ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\ PURPOSE. See the GNU General Public License for more
\ details.
\ You should have received a copy of the GNU General Public
\ License along with this program; if not, see
\ <http://gnu.org/licenses>.
\ ==============================================================
\ Requirements {{{1
forth_definitions
require galope/s-comma.fs \ `s,`
\ ==============================================================
\ Custom language markup tools {{{1
fendo_definitions
\ XXX TODO nested, with depth counter?
0 [if]
\ In order to markup the language of the contents, the website
\ application must create the language specific markups for the
\ required languages, this way:
language_markup: eo
language_markup: es
For every language, the following markups are created:
- `lang((` for inline zones
- `lang((((` for block zones
- `lang''` for inline quotes
- `lang''''` for block quotes
Usage example:
In English you say: Hello world!
In Esperanto you say eo'' Saluton, mondo! ''
In Spanish you say: es'' ¡Hola mundo! ''
Please do it la(( ipso facto )) , es(( gracias )) .
[then]
: language_inline_markup ( ca len -- )
2dup s" ((" s+ :create_markup s,
does> ( -- ) ( dfa ) count (xml:)lang=! [<span>] ;
\ Create a language inline markup.
\ ca len = ISO code of a language
: language_inline_quote_markup ( ca len -- )
2dup s" ''" s+ :create_markup s,
does> ( -- ) ( dfa ) count (xml:)lang=! [markup>order] '' [markup<order] ;
\ Create a language inline quote markup.
\ ca len = ISO code of a language
: language_block_markup ( ca len -- )
2dup s" ((((" s+ :create_markup s,
does> ( -- ) ( dfa ) count (xml:)lang=! [<div>] ;
\ Create a language block markup.
\ ca len = ISO code of a language
: language_block_quote_markup ( ca len -- )
2dup s" ''''" s+ :create_markup s,
does> ( -- ) ( dfa ) count (xml:)lang=! [markup>order] '''' [markup<order] ;
\ Create a language block quote markup.
\ ca len = ISO code of a language
: language_markup: ( "name" -- )
parse-name? abort" Expected language code"
2dup language_inline_markup 2dup language_inline_quote_markup
2dup language_block_markup language_block_quote_markup ;
\ Create inline and block language and quote markups.
\ Used by the website application to create all
\ language markups used in the contents.
\ name = ISO code of a language
.( fendo.markup.fendo.language.fs compiled ) cr
\ ==============================================================
\ Change log {{{1
\ 2014-04-21: Code moved from <fendo.markup.fendo.fs>.
\
\ 2014-06-06: `)))` changed to `))))`, after the last changes in
\ Fendo's markup.
\
\ 2014-07-13: New: inline and block quotes.
\
\ 2014-11-09: The usage text is updated.
\
\ 2017-06-22: Update source style, layout and header.
\
\ 2018-12-06: Improve documentation.
\
\ 2018-12-08: Update notation of Forth words in comments and strings.
\
\ 2021-04-29: Require `s,`, word removed from Gforth between versions
\ 0.7.9_20201231 and 0.7.9_20210422, and added to Galope.
\ vim: filetype=gforth