#
#  Copyright (C) 2010-2011 by DocArch <http://www.docarch.be>
#  Copyright (C) 2014-2015, 2019 by Bert Frees
#  Copyright (C) 2014 by CBB <http://www.cbb.nl>
#  Copyright (C) 2015, 2016, 2018 by Dedicon <http://www.dedicon.nl>
#
#  This file is part of liblouis.
#
#  liblouis is free software: you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation, either version 3 of the
#  License, or (at your option) any later version.
#
#  liblouis 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
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with liblouis. If not, see
#  <http://www.gnu.org/licenses/>.
#
# -------------------------------------------------------------------------------
#
#  Dutch Braille based on the braille standard of 2017
#
#     Created by Bert Frees <bertfrees@gmail.com>
#     Modified by Henri Apperloo <h.apperloo@cbb.nl>
#     Modified by Davy Kager <DavyKager@dedicon.nl>
#
#     See also: « Braillestandaard voor algemeen gebruik in het Nederlandse taalgebied,
#                Van toepassing vanaf 19 april 2018 »
#              (Braille Autoriteit, 2018)
#               [http://liblouis.org/braille-specs/dutch][1]
#
# ----------------------------------------------------------------------------------------------

include nl-chardefs.uti
include braille-patterns.cti

hyphen    \x002D  36

# §3.1 Het cijferteken [1]

midnum    \x002C  2    # COMMA
midnum    \x002E  256  # FULL STOP

# §1.55 Paragraafteken [1]

begword \x00A7   346-0
midword \x00A7 0-346-0
endword \x00A7 0-346

# §2.18 Procent- en promilleteken [1]

endnum  \x0025 0-123456
endnum  \x2030 0-123456-123456

# §3.2 De basisrekentekens (spatieregel) [1]

# isgelijkteken =
begword \x003D   2356-0
midword \x003D 0-2356-0
endword \x003D 0-2356

# plusteken +
begword \x002B   235-0
endnum  \x002B 5-235

# deelteken ÷
begword \x00F7   256-0
midword \x00F7 0-256-0
endword \x00F7 0-256

# maalteken ×
begword \x00D7   236-0
midword \x00D7 0-236-0
endword \x00D7 0-236

# §2.17 Muntsymbolen/valutatekens [1]
# Als de munteenheid na het getal wordt geplaatst, dan wordt ze bij voorkeur voluit geschreven
noback correct ["€"]$s.!$d "euro"
noback correct ["$"]$s.!$d "dollar"
noback correct ["£"]$s.!$d "pond"
noback correct ["¥"]$s.!$d "yen"
noback correct ["€"]$s.~   "euro"
noback correct ["$"]$s.~   "dollar"
noback correct ["£"]$s.~   "pond"
noback correct ["¥"]$s.~   "yen"
noback correct ["€"]!$ds   "euro"
noback correct ["$"]!$ds   "dollar"
noback correct ["£"]!$ds   "pond"
noback correct ["¥"]!$ds   "yen"
noback correct ["€"]~      "euro"
noback correct ["$"]~      "dollar"
noback correct ["£"]~      "pond"
noback correct ["¥"]~      "yen"

# Geplaatst vóór het getal wordt de munteenheid door haar beginletter weergegeven, zonder spatie tussen letter en cijfer

# §1.5 euroteken € (zonder spatie vóór het getal) [1]
noback joinnum \x20AC 15

# §1.4 dollarteken $ (zonder spatie vóór het getal) [1]
noback joinnum \x0024 145

# §1.16 pondteken £ (zonder spatie vóór het getal) [1]
noback joinnum \x00A3 1234

# §1.24 yenteken ¥ (zonder spatie vóór het getal) [1]
noback joinnum \x00A5 13456

# §1.34 verticale streep | (spatie voor en na) [1]

begword \x007C   1456-0
midword \x007C 0-1456-0
endword \x007C 0-1456

# §3.6 Graad-, minuut- en secondeteken [1]
noback context $d["''"] @4-35-35
noback context $d["'"] @4-35

# Roman page numbers
replace  \\_

# §2.11 Herstelteken [1]

# For numbers that are immediately followed by a letter a-j, a sign must be
# inserted for terminating the number.

# Using these rules instead of the multipass rules makes a lot of tests fail:
# nocontractsign 6
# numericnocontchars abcdefghij

attribute digitletter abcdefghijABCDEFGHIJ    # 1st class = $w
noback context     $d[]%digitletter       @6
noback context     $d","[]%digitletter    @6
noback context     $d"."[]%digitletter    @6
noback context     $d":"[]%digitletter    @6
# Multiple dots 6 are collapsed into a single dot 6.
noback pass2       [@6]@6                 ?
# A dot 6 is not needed when the number is already cancelled by a capital or emphasis sign
noback pass3       $d[@6]@45              ?
noback pass3       $d[@6]@46              ?
noback pass3       $d[@6]@456             ?

# §2.20 Sleutelteken tweede betekenis [1]

# §2.3 Ampersandteken [1]

# When an AMPERSAND appears within a word (e.g. an initialism like AT&T) it must be
# preceded by a "second meaning" sign because its first meaning is LETTER C WITH
# CEDILLA (ç).

# When a PLUS SIGN appears within a word (e.g. 30+'er) it must be preceded by a
# "second meaning" sign because its first meaning is EXCLAMATION MARK.

attribute    plusamp                     +&     # 2nd class = $x
attribute    noplusamp                   .'‘’   # 3rd class = $y
noback pass4    %noplusamp[]%plusamp        @5
noback pass4    $l[]%plusamp                @5
noback pass4    [@235a]%plusamp             @235-5
noback pass4    [@12346a]%plusamp           @12346-5
noback pass4    [@235a]                     @235
noback pass4    [@12346a]                   @12346

numsign  3456

# §1.58 Drukwijzigingsteken [1]
emphclass italic
emphclass underline
emphclass bold

lenemphphrase italic 4
begemphword italic 456
endemphword italic 6
begemphphrase italic 456-456
endemphphrase italic before 456
emphletter italic 456

lenemphphrase bold 4
begemphword bold 456
endemphword bold 6
begemphphrase bold 456-456
endemphphrase bold before 456
emphletter bold 456

lenemphphrase underline 4
begemphword underline 456
endemphword underline 6
begemphphrase underline 456-456
endemphphrase underline before 456
emphletter underline 456

# §2.12 Hoofdletters [1]

# Certain characters can appear within an uppercase string without cancelling
# the uppercase "state". These characters are + (PLUS SIGN), & (AMPERSAND),
# . (FULL STOP), ' (APOSTROPHE), ‘ (LEFT SINGLE QUOTATION MARK)
# and ’ (RIGHT SINGLE QUOTATION MARK).
capsmodechars +&.'‘’
# The same goes for the emphasis "state".
emphmodechars italic +&.'
emphmodechars bold +&.'
emphmodechars underline +&.'

# These are the characters for which emphasis is not indicated
noemphchars italic \s'()
noemphchars bold \s'()
noemphchars underline \s'()

# treat apostrophe in 't as a letter
letter \xe000 3
noback correct ["'"]"t"$s "\xe000"

lencapsphrase 4
begcapsword 45
endcapsword 6
begcapsphrase 45-45
endcapsphrase before 45
capsletter 46
