# liblouis: Norwegian literary braille, 6-dot, uncontracted
#
#-name: Norsk litterær punktskrift, 6-punkt, fullskrift
#-index-name: Norwegian, uncontracted, 6-dot
#-display-name: Norwegian 6-dot uncontracted braille
#
#+language:no
#+language:nb
#+language:nn
#+type:literary
#+direction:both
#+contraction:no
#+dots:6
#+grade:0
#
#  Copyright (C) 2005 ViewPlus Technologies, Inc. www.viewplus.com
#  Copyright (C) 2009-2010, 2012-2013, 2017, 2019, 2021-2022, 2025 Lars Bjørndal <lars@lamasti.net>
#  Copyright (C) 2015-2018 NLB Norwegian library of talking books and braille, http://www.nlb.no/
#  Copyright (C) 2025 Bert Frees
#
#-copyright: 2005, ViewPlus Technologies, Inc. www.viewplus.com
#-copyright: 2009-2025, Lars Bjørndal
#-copyright: 2015-2018, Norwegian library of talking books and braille (NLB), http://www.nlb.no/
#-copyright: 2025, Bert Frees
#-license: LGPLv2.1
#
# Created June 9, 2005 by Leon Ungier <Leon.Ungier@ViewPlus.com> with
# help and guidance from Lars Bjørndal <lars@lamasti.net>
# Updated June 2009 by Lars Bjørndal <lars@lamasti.net>
# Updated April 2015 by Jostein Austvik Jacobsen <jostein@nlb.com> and Ammar Usama <ammar.usama@nlb.no>
# Updated February 2025 by Lars Bjørndal <lars@lamast.net>
#
#-author: Leon Ungier <Leon.Ungier@ViewPlus.com>
#-author: Lars Bjørndal <lars@lamasti.net>
#-author: Jostein Austvik Jacobsen <jostein@nlb.no>
#-author: Ammar Usama <ammar.usama@nlb.no>
#
# Official norwegian braille specifications are collected here:
# http://liblouis.io/braille-specs/norwegian
# This specific table is based on the document "Håndbok i litterær punktskrift".
#
# Input is expected to be normalized to NFC (fully composed)
#-unicode-form:nfc
#
#  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/>.
#

include no-no.dis
include no-no-chardefs6.uti
include litdigits6Dots.uti
include braille-patterns.cti # unicode braille
include no-no-cyrillic6dot.uti

# comp6 definitions
comp6 A 6-1
comp6 B 6-12
comp6 C 6-14
comp6 D 6-145
comp6 E 6-15
comp6 F 6-124
comp6 G 6-1245
comp6 H 6-125
comp6 I 6-24
comp6 J 6-245
comp6 K 6-13
comp6 L 6-123
comp6 M 6-134
comp6 N 6-1345
comp6 O 6-135
comp6 P 6-1234
comp6 Q 6-12345
comp6 R 6-1235
comp6 S 6-234
comp6 T 6-2345
comp6 U 6-136
comp6 V 6-1236
comp6 W 6-2456
comp6 X 6-1346
comp6 Y 6-13456
comp6 Z 6-1356
comp6 Æ 6-345
comp6 Ø 6-246
comp6 Å 6-16
#lowword \x2013 36-36         # make double when surrounded by white spaces
#lowword - 36-36              # make double when hyphen surrounded by white spaces

numsign 3456

# Fix less-than / greater-than when in math context
always <\s 246-3-0
always <- 246-3-36
always -> 36-135-2
always \s> 0-135-2
noback context ["<"]$d @246-3
noback context _$d["<"] @246-3
noback context [">"]$d @135-2
noback context _$d[">"] @135-2
capsletter 6
begcapsword 69-6
noback endcapsword 569
begcapsphrase 6-6-6
lencapsphrase 2
endcapsphrase after 6

# variable #1 keeps track of when begcapsword has been suppressed
noback pass2 _!$sp[@69-6]          ?#1=1   # suppress begcapsword when it is not the first character of the word
noback pass2 [@69-6]$l.@569@234$sp @6-6    # suppress begcapsword if it needs to be terminated by a endcapsword,
noback pass2 [@69-6]$l.@569@234~   @6-6    # unless the endcapsword is followed by a single "s"
noback pass2 [@69-6]$l.@569        ?#1=1   #
noback pass2 #1=1[]$l              @6      # insert capsletter before (uppercase) letter if begcapsword was suppressed
noback pass2 #1=1@569              ?#1=0   # caps mode is terminated by endcapsword; suppress endcapsword if
                                           # begcapsword was suppressed
noback pass2 #1=1!$l               *#1=0   # caps mode is terminated by character that is not a letter

# remove dot 9
swapdd cleanvirtual 69,569 6,56
noback pass4 %cleanvirtual %cleanvirtual

# backward direction
nofor pass4 _!$sp[@6@6] @69-6#1=1
nofor pass4 #1=1@56 @569#1=0
nofor pass4 #1=1!$l *#1=0

emphclass italic
emphclass underline
emphclass bold


# We want backtranslation of semicolon.
noback begemph italic 23
begemph bold 6-3
begemph underline 456

noback endemph italic 56
endemph bold 6-3
endemph underline 456


# endnum # 56-3456
noback always # 3456
nonumsign 56
numericnocontchars abcdefghij
midendnumericmodechars ,.:
repeated ... 3-3-3           # points de suite
repeated --- 36-36-36
repeated ___ 456-456-456

# always \s--\s 36-36        # tiret
noback always ;\s; 0

# Fix quotation mark before and after dollar sign
always "$ 256-6-256
always «$ 256-6-256
always ‘$ 256-6-256
always „$ 256-6-256
always “$ 256-6-256
always $" 256-6-256
always $» 256-6-256
always $’ 256-6-256
always $„ 256-6-256
always $” 256-6-256


always °) 5-356-6-356


# We have to redefine the letter æ here to prevent back translation of it to result in a space

lowercase \x00E6 345          # æ 00E6
base uppercase \x00C6 \x00E6  # æ x00C6 / 00E6

# URLs
nocont ://
nocont www.
nocont .com
nocont .edu
nocont .gov
nocont .mil
nocont .net
nocont .org
nocont .no
nocont .nu
nocont .se
nocont .dk
nocont .fi
nocont .ini
nocont .doc
nocont .docx
nocont .xml
nocont .xsl
nocont .htm
nocont .html
nocont .tex
nocont .txt
nocont .gif
nocont .jpg
nocont .png
nocont .wav
nocont .mp3
nocont .m3u
nocont .tar
nocont .gz
nocont .bz2
nocont .zip

# Fix input where less than / greater than already are surrounding the
# URL / email address.
noback pass2 @126-246-3 @126
noback pass2 @135-2-345 @345
noback pass2 @3456-3456 @3456-6-3456

# remove space after degree sign and before C (Celcius), F (Fahrenheit) or K (Kelvin)
noback pass2 @5-356-0-6-14 @5-356-6-14    # ° C
noback pass2 @5-356-0-6-124 @5-356-6-124  # ° F
noback pass2 @5-356-0-6-13 @5-356-6-13    # ° K

# subscript
# ---------

emphclass sub
emphletter sub 16
begemph sub 16-236
noback endemph sub 356

digit ₀ 245a
digit ₁ 1a
digit ₂ 12a
digit ₃ 14a
digit ₄ 145a
digit ₅ 15a
digit ₆ 124a
digit ₇ 1245a
digit ₈ 125a
digit ₉ 24a

# ₊ ₋ ₌ ₍ ₎ ₐ ₑ ₒ ₓ ₔ ⱼ ᵢ ᵣ ᵤ ᵥ ᵦ ᵧ ᵨ ᵩ ᵪ

attribute sub ₀₁₂₃₄₅₆₇₈₉

noback pass2 %sub%sub. @16-236*
noback pass2 %sub @16*
noback pass3 %sub%sub. *@356

# fix order of sub sign and number sign
noback pass3 @3456-16-236 @16-236-3456
noback pass3 @3456-16 @16-3456

noback pass4 @245a  @245  # ₀
noback pass4 @1a    @1    # ₁
noback pass4 @12a   @12   # ₂
noback pass4 @14a   @14   # ₃
noback pass4 @145a  @145  # ₄
noback pass4 @15a   @15   # ₅
noback pass4 @124a  @124  # ₆
noback pass4 @1245a @1245 # ₇
noback pass4 @125a  @125  # ₈
noback pass4 @24a   @24   # ₉

# superscript
# -----------

emphclass super
emphletter super 46
begemph super 46-236
noback endemph super 346

digit ⁰ 245b
digit ¹ 1b
digit ² 12b
digit ³ 14b
digit ⁴ 145b
digit ⁵ 15b
digit ⁶ 124b
digit ⁷ 1245b
digit ⁸ 125b
digit ⁹ 24b
# ⁱ ⁺ ⁻ ⁼ ⁽ ⁾ ⁿ ª º ⱽ ᴮ ᴯ ᴰ ᴱ ᴲ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴻ ᴼ ᴽ ᴾ ᴿ ᵀ ᵁ ᵂ ᵃ ᵄ ᵅ ᵆ ᵇ ᵈ ᵉ ᵊ ᵋ ᵌ ᵍ ᵏ ᵐ ᵑ ᵒ ᵓ ᵖ ᵗ ᵘ ᵚ ᵛ ᵝ ᵞ ᵟ ᵠ ᵡ

attribute super ⁰¹²³⁴⁵⁶⁷⁸⁹

noback pass2 %super%super. @46-236*
noback pass2 %super @46*
noback pass3 %super%super. *@356

# fix order of super sign and number sign
noback pass3 @3456-46-236 @46-236-3456
noback pass3 @3456-46 @46-3456

noback pass4 @245b  @245  # ⁰
noback pass4 @1b    @1    # ¹
noback pass4 @12b   @12   # ²
noback pass4 @14b   @14   # ³
noback pass4 @145b  @145  # ⁴
noback pass4 @15b   @15   # ⁵
noback pass4 @124b  @124  # ⁶
noback pass4 @1245b @1245 # ⁷
noback pass4 @125b  @125  # ⁸
noback pass4 @24b   @24   # ⁹

# 9.6 Percent/promille
noback context [$s]"%" ?
noback context [$s]"‰" ?
noback context "%"[")"] @6-356
noback context "‰"[")"] @6-356

# 11.3 Pound sign
noback joinnum \x00A3 123
