# Liblouis: Danish table for 6 dots grade 1 forward and backward translation 2022
#
#  Copyright (C) 2014, 2016-2023, Bue Vester-Andersen <bue@vester-andersen.dk>
#
#  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 2.1 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/>.
#
# This  is the Danish table for 6 dots grade 1 Braille (fuldskrift) DDP2022.
# Use this table for translation and back-translation of Danish 6 dots grade 1 Braille.
# See also: Den Danske Punktskrift 2022
#           Det Danske Punktskriftsnævn
#           https://www.blind.dk/punktskrift-2022
#
# Version: Bue Vester-Andersen, December 2022

### Table Metadata

#-name: Dansk fuldskrift 6-punkt 2022
#-index-name: Danish, uncontracted, 6-dot, 2022
#-display-name: Danish 6-dot uncontracted braille (2022 standard)

#+language: da
#+type: literary
#+contraction: no
#+grade: 1
#+dots: 6
#+direction: both
#+system: ddp
#+version: 2022

# Display opcodes
include da-dk-octobraille.dis

### Spaces
include spaces.uti

### Character definitions

# Definition of dot cells
punctuation ! 235 EXCLAMATION MARK
punctuation " 2356 QUOTATION MARK
sign & 12346 AMPERSAND
punctuation ' 4 APOSTROPHE
punctuation ( 236 LEFT PARENTHESIS
punctuation ) 356 RIGHT PARENTHESIS
punctuation * 35 ASTERISK
punctuation , 2 COMMA
punctuation - 36 HYPHEN-MINUS
punctuation . 3 FULL STOP
punctuation / 34 SLASH
punctuation : 25 COLON
punctuation ; 23 SEMICOLON
punctuation ? 26 QUESTION MARK
include latinLetterDef6Dots.uti

include digits6Dots.uti

punctuation \x00a7 346 SECTION SIGN (0xa7)

lowercase \x00e0 12356 LATIN LETTER A WITH GRAVE
lowercase \x00e5 16 LATIN LETTER A WITH RING ABOVE
lowercase \x00e6 345 LATIN LETTER AE
lowercase \x00e8 2346 LATIN LETTER E WITH GRAVE
lowercase \x00e9 123456 LATIN LETTER E WITH ACUTE
lowercase \x00f8 246 LATIN LETTER O WITH STROKE
lowercase \x00fc 1256 LATIN LETTER U WITH DIAERESIS

base uppercase \x00c0 \x00e0 LATIN LETTER A WITH GRAVE
base uppercase \x00c5 \x00e5 LATIN LETTER A WITH RING ABOVE
base uppercase \x00c6 \x00e6 LATIN LETTER AE
base uppercase \x00c8 \x00e8 LATIN LETTER E WITH GRAVE
base uppercase \x00c9 \x00e9 LATIN LETTER E WITH ACUTE
base uppercase \x00d8 \x00f8 LATIN LETTER O WITH STROKE
base uppercase \x00dc \x00fc LATIN LETTER U WITH DIAERESIS


# cover all other Braille patterns
include braille-patterns.cti

# Characters with two or more cells

punctuation # 45-3456 NUMBER SIGN
sign $ 45-145 DOLLAR SIGN
math % 245-356 PERCENT SIGN
math + 45-235 PLUS SIGN
math < 45-134 LESS-THAN SIGN
math = 45-2356 EQUALS SIGN
math > 45-234 GREATER-THAN SIGN
sign @ 45-1 COMMERCIAL AT
punctuation [ 5-236 LEFT SQUARE BRACKET
punctuation \\ 45-34 REVERSE SLASH
punctuation ] 5-356 RIGHT SQUARE BRACKET
punctuation ^ 45-346 CIRCUMFLEX ACCENT
punctuation _ 45-36 LOW LINE
punctuation ` 4 GRAVE ACCENT
punctuation { 45-246 LEFT CURLY BRACKET
punctuation | 45-1236 VERTICAL LINE
punctuation } 45-135 RIGHT CURLY BRACKET
punctuation ~ 45-23 TILDE
math \x00f7 45-256 DIVISION SIGN

# Misc unicode characters
include da-dk-6miscChars.cti

# Litdigits
include litdigits6Dots.uti
midendnumericmodechars /,.:^
undefined 26

### Braille indicators and special characters

#hyphen - 36

letsign 56

# No letsign before normal letters or letters with accents
# Letters with accents are handled by pass2.
noletsign ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅÀÄÈÉÖÜ\x0152
noletsign abcdefghijklmnopqrstuvwxyzæøåàäèéöü\x00df\x0149\x0153

# Emphasis opcodes
emphclass italic
emphclass underline
emphclass bold

begemphphrase italic 46
endemphphrase italic after 46

begemphphrase bold 46
endemphphrase bold after 46

begemphphrase underline 46
endemphphrase underline after 46

capsletter 6
begcapsword 456
endcapsword 56
multind 56-6 letsign capsletter
multind 6-56 capsletter letsign
multind 46-456 letsign begcapsword

numsign 3456
multind 56-3456 letsign numsign

#class of none-space characters that demand double dashes
# Used in context lines later.
#must be the first class defined.
attribute charsWDoubleDash .,?!/:"'() # class w

### Correct - forward translation

# Chars that don't require a space before percent and permille:
attribute charsBeforePercent "(\x201e\x0084\x201c\x0093\x201d\x0094\x00ab\x00bb #class x
noback correct `["%"] *
noback correct !$sx["%"] " %"
noback correct `["\x2030"] *
noback correct !$sx["\x2030"] " \x2030"
noback correct `["\x0089"] *
noback correct !$sx["\x0089"] " \x2030"

# Chars to be treated like digits when switching back to letter mode
attribute extraDigits \x00bc\x00bd\x00be

#Use the "correct" opcode to convert chars that can't be back-translated
# and make the table more simple.

# Dashes
attribute dashes \x2013\x2014\x0096\x0097\x00ad
noback correct %dashes "-"

attribute quotes \x201e\x0084\x201c\x0093\x201d\x0094\x00ab\x00bb 
noback correct %quotes "\""

attribute apostrophes `\x201a\x0082\x2039\x008b\x2018\x0091\x2019\x0092\x203a\x009b\x00b4
noback correct %apostrophes "'"

### Correct - backward translation

# characters that may get mangled by the insertion of extra letsigns
nofor correct "\x2818" "~"
#nofor correct "\x282f" "&"
#nofor correct "\x2814" "*"

nofor correct "\x28a0" ? # Extraneous endcaps signs
#nofor correct "\x2820" ?
nofor correct "~\\456/" "|"

### Pass 1 - Forward and backward

# Punctuations, math and numbers
#midnum , 2
#midnum . 3
#midnum - 36
endnum - 36
#midnum / 34
#midnum : 25

midnum ^ 45-346
midnum \x00d7 45-35

# Punctuation
prepunc " 2356
postpunc " 2356
prepunc - 36
postpunc - 36
nofor always \s-\s 0-36-36-0
always :- 25-36
always ;- 23-36
always --- 36-36-36
always ---- 36-36-36-36
always ----- 36-36-36-36-36

# these characters must be separated from ")" by a letsign.
attribute SepToRightpar Jj%\x2030\x0089\x201a\x0082\x2039\x009b\x2018\x0091\x2019\x0092\x203a\x009b
after SepToRightpar always ) 56-356

prepunc ( 236
postpunc ) 356

always .) 3-356
always ... 3-3-3

always !! 235-235
always !!! 235-235-235
always !!!! 235-235-235-235
always !!!!! 235-235-235-235-235

### Context rules - forward translation

# Ensure two dashes where appropriate.
noback context $w["-"]$w @36
noback context $sw["-"]$sw @36-36
noback context `["-"]$sw @36-36
noback context $sw["-"]~ @36-36
noback context !$sw["-"]~ @36
noback context `["-"]~ @36-36

#ensure letsign between a digit and a letter
noback context $dy[]$u @56
noback context $dy$Spm.[]$u @56

### context - backward translation

# Ensure the correct number of dashes
nofor context @36[@36-36] "--"
nofor context [@36-36]@36 "--"
nofor context $w[@36-36]$w "--"
nofor context $sw[@36-36]$sw "-"
nofor context `[@36-36]$sw "-"
nofor context $sw[@36-36]~ "-"
nofor context `@36-36~ "-"


### Pass 2 - forward translation

noback pass2 @56-5 @5 # no letsign before letters with accent
noback pass2 @56-6-5 @6-5 # no letsign before cap letters with accent
noback pass2 @56-6 @6-56 # Ensure correct order

### Pass 2 - backward

### Pass 3 - forward translation

# Ensure there is only one letsign
noback pass3 @56-56 @56

# Ensure there is only one emphasis sign
noback pass3 @46-46 @46
noback pass3 @46-46-46 @46