# Liblouis: Danish table for 6 dots grade 1 forward translation (literary) 1993
#
#  Copyright (C) 2014, 2016-2021, 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  6 dots grade 1 table for forward translation (literary / not back-translateable) 1993.
# 
# The output from this table is mainly ment for embossing and not suited for back-translation.
#
# Version: Bue Vester-Andersen, December 2022

### Table Metadata

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

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

# Display opcodes
include da-dk-octobraille_1993.dis

### Spaces

# These ctrl-chars have to have a representation, so that they can be properly converted back and forth.
space \t 2478 CHARACTER TABULATION
space \n 678 LINE FEED (LF)
space \v 1368 LINE TABULATION
space \f 12378 FORM FEED (FF)
space \r 257 CARRIAGE RETURN (CR)
space \x00a0 a

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 \x00e5 16 LATIN LETTER A WITH RING ABOVE
lowercase \x00e6 345 LATIN LETTER AE
lowercase \x00f8 246 LATIN LETTER O WITH STROKE
lowercase \x00fc 1256 LATIN LETTER U WITH DIAERESIS
math \x00f7 256 DIVISION SIGN

# Uppercase letters
base uppercase \x00c5 \x00e5 LATIN LETTER A WITH RING ABOVE
base uppercase \x00c6 \x00e6 LATIN LETTER AE
base uppercase \x00d8 \x00f8 LATIN LETTER O WITH STROKE
base uppercase \x00dc \x00fc LATIN CAPITAL 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-256 DOLLAR SIGN
math % 245-356 PERCENT SIGN
#sign & 6-12346 AMPERSAND
#punctuation * 6-35 ASTERISK
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-16 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-456 VERTICAL LINE
punctuation } 45-135 RIGHT CURLY BRACKET
punctuation ~ 45-6 TILDE

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

# Litdigits
include litdigits6Dots.uti

undefined 26

### Braille indicators and special characters

#hyphen - 36

letsign 6

# 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 56
endemphphrase italic after 56

begemphphrase bold 56
endemphphrase bold after 56

begemphphrase underline 56
endemphphrase underline after 56

capsletter 46 
begcapsword 456
endcapsword 6

numsign 3456

#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

# 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 `["\x2030"] *
noback correct !$sx["%"] " %"
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 "'"

# Convert most single caps to lowercase

#Special abbreviations with imbedded small letters.
# Must be handled by case in this version of liblouis
noback correct "KAbB" "KABB"
noback correct "CUDiM" "CUDIM"

swapcc UpperLower ABCDEFGHIJKLMNOPQRSTUVWXYZ\x00c0\x00c1\x00c2\x00c3\x00c4\x00c5\x00c6\x00c7\x00c8\x00c9\x00ca\x00cb\x00cc\x00cd\x00ce\x00cf\x00d0\x00d1\x00d2\x00d3\x00d4\x00d5\x00d6\x00d8\x00d9\x00da\x00db\x00dc\x00dd\x00de\x008a\x008c abcdefghijklmnopqrstuvwxyz\x00e0\x00e1\x00e2\x00e3\x00e4\x00e5\x00e6\x00e7\x00e8\x00e9\x00ea\x00eb\x00ec\x00ed\x00ee\x00ef\x00f0\x00f1\x00f2\x00f3\x00f4\x00f5\x00f6\x00f8\x00f9\x00fa\x00fb\x00fc\x00fd\x00fe\x009a\x009c
swapcc UpperLowerExt \x0100\x0102\x0104\x0106\x0108\x010a\x010c\x010e\x0110\x0112\x0114\x0116\x0118\x011a\x011c\x011e\x0120\x0122\x0124\x0126\x0128\x012a\x012c\x012e\x0130\x0132\x0134\x0136\x0139\x013b\x013d\x013f\x0141\x0143\x0145\x0147\x014a\x014c\x014e\x0150\x0152\x0154\x0156\x0158\x015a\x015c\x015e\x0160\x0162\x0164\x0166\x0168\x016a\x016c\x016e\x0170\x0172\x0174\x0176\x0178\x0179\x017b\x017d\x0386\x0388\x0389\x038a\x038c\x038e\x038f\x0391\x0392\x0393\x0394\x0395\x0396\x0397\x0398\x0399\x039a\x039b\x039c\x039d\x039e\x039f\x03a0\x03a1\x03a3\x03a4\x03a5\x03a6\x03a7\x03a8\x03a9 \x0101\x0103\x0105\x0107\x0109\x010b\x010d\x010f\x0111\x0113\x0115\x0117\x0119\x011b\x011d\x011f\x0121\x0123\x0125\x0127\x0129\x012b\x012d\x012f\x0131\x0133\x0135\x0137\x013a\x013c\x013e\x0140\x0142\x0144\x0146\x0148\x014b\x014d\x014f\x0151\x0153\x0155\x0157\x0159\x015b\x015d\x015f\x0161\x0163\x0165\x0167\x0169\x016b\x016d\x016f\x0171\x0173\x0175\x0177\x00ff\x017a\x017c\x017e\x03ac\x03ad\x03ae\x03af\x03cc\x03cd\x03ce\x03b1\x03b2\x03b3\x03b4\x03b5\x03b6\x03b7\x03b8\x03b9\x03ba\x03bb\x03bc\x03bd\x03be\x03bf\x03c0\x03c1\x03c3\x03c4\x03c5\x03c6\x03c7\x03c8\x03c9

# I is a special case
noback correct _$sp["I"]$sp "i"
noback correct `["I"]$sp "i"
noback correct _$sp["I"]~ "i"

noback correct $sSpu[%UpperLower]$u %UpperLower
noback correct `[%UpperLower]$u %UpperLower

noback correct $sSpu[%UpperLowerExt]$u %UpperLowerExt
noback correct `[%UpperLowerExt]$u %UpperLowerExt

# Punctuations, math and numbers
midnum , 2
midnum . 3
# the following rule is doubtful, but probably does not apply.
#midnum - 36
endnum - 36
midnum / 34
midnum : 25

midnum ^ 45-346
midnum \x00d7 45-3-3456

# Remove space between § and numbers.
begnum § 346
begnum §\s 346
begnum §§\s 346-346
always §§ 346-346

# Punctuation
prepunc " 2356
postpunc " 2356
prepunc - 36
postpunc - 36
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 ) 6-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

# Substitutions for joinnum rules with common math signs
noback context $dy$s["-"$s]$dy @36
noback context $dy$s["+"$s]$dy @235
noback context $dy$s["\x00d7"$s]$dy @3
noback context $dy$s["\x00f7"$s]$dy @256
noback context $dy$s["="$s]$dy @2356

# Space on each side of = when between letters or punctuation.
noback context $lp["="]$lp @0-2356-0

# 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 dot 6 between a digit and a letter
noback context $dy[]$u @6
noback context $dy$Spm.[]$u @6

# Ensure dot 6 as nocaps
#noback context $U2-50[]$u @6

### Pass 2

noback pass2 @6-5 @5 # no letsign before letters with accent
noback pass2 @6-46-5 @46-5 # no letsign before cap letters with accent
noback pass2 @45-6-46 * # don't touch tilde before capnoback pass2 @6-46 @46-6 # Ensure correct order

# Ensure there is only one letsign
noback pass2 @6-6 @6

# Ensure there is only one emphasis sign
noback pass2 @56-56 @56
noback pass2 @56-56-56 @56
