# liblouis: Unified English Braille Code (Grade 1)
#
# -----------
#-name: Unified English braille, grade 1
#-index-name: English, unified, uncontracted
#-display-name: Unified English uncontracted braille
#
#+language:en
#+type:literary
#+contraction:no
#+grade:1
#+system:ueb
#
# TODO: Please add a reference to official documentation about
# the implemented braille code. Preferably submit the documents
# to https://github.com/liblouis/braille-specs.
# -----------
#
#  Copyright (C) 2004-2008 ViewPlus Technologies, Inc. www.viewplus.com
#  Copyright (C) 2004-2006 JJB Software, Inc. www.jjb-software.com
#  Copyright (C) 2016 American Printing House for the Blind, Inc. www.aph.org
#  Copyright (C) 2016 Joseph Lee <joseph.lee22590@gmail.com>
#  Copyright (C) 2021 RNIB, www.rnib.org.uk
#
#  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/>.
#
#-maintainer: James Bowden <james.bowden@rnib.org.uk>
#-author: John J. Boyer <john.boyer@jjb-software.com>
#-author: Mike Gray <mgray@aph.org>
#-author: Joseph Lee <joseph.lee22590@gmail.com>

include en-ueb-chardefs.uti UEB specific char defs.
#   some dots are undefined now
include en-ueb-math.ctb UEB math from common linear format

numsign 3456  number sign, just a dots operand
numericmodechars .,
nocontractsign 56
nonumsign 56
numericnocontchars abcdefghijABCDEFGHIJ

# A capital ends numeric mode, so clean up extraneous letter indicators between a number
# and a subsequent capital letter
noback pass2 _$D[@6-56]$U @6                # handle "1234Card"
noback pass2 _$D[@6-6-56]$U @6-6            # handle "1234CARD"
noback pass2 _$D[@256-6-6-56]$U @256-6-6    # handle "1234.CARD"
noback pass2 _$D[@256-6-56]$U @256-6        # handle "1234.Card"

# Correct order of comma and numeric indicator
match %a , %# 2-34569  force correct position of numeric indicator
noback pass2 @3456-2-34569 @2-3456    Clear up extra indicator after the match line

# Correct order of dot and numeric indicator
match %a . %# 256-34569  force correct position of numeric indicator
noback pass2 @3456-256-34569 @256-3456    Clear up extra indicator after the match line

# numeric space
noback correct _$d["\x00a0"]$d     "\xE020"   # change space to custom symbol representing numeric space
nofor  correct _$d["\xE020"]$d "\x00a0"
litdigit \xE020 5a                        # add virtual dot to make distinction with other uses of dot 5
noback pass2   @5a             @5
nofor  pass2   [@3456]$D       @3456#1=1  # enter numeric mode when number sign followed by digit is encountered
nofor  pass2   $D              *
nofor  pass2   #1=1[@5]$D      @5a        # when in numeric mode interpret dot 5 as numeric space
nofor  pass2   $a              *#1=0      # exit numeric mode when other character than digit or numeric space is encountered

capsletter 6
begcapsword 6-6
endcapsword 6-3
lencapsphrase 3
begcapsphrase 6-6-6
endcapsphrase after 6-3

emphclass italic
emphclass underline
emphclass bold
emphclass script
emphclass transnote
emphclass trans1
emphclass trans2
emphclass trans3
emphclass trans4
emphclass trans5

emphletter italic 46-23
begemphword italic 46-2
endemphword italic 46-3
lenemphphrase italic 3
begemphphrase italic 46-2356
endemphphrase italic after 46-3

emphletter bold 45-23
begemphword bold 45-2
endemphword bold 45-3
lenemphphrase bold 3
begemphphrase bold 45-2356
endemphphrase bold after 45-3

emphletter underline 456-23
begemphword underline 456-2
endemphword underline 456-3
lenemphphrase underline 3
begemphphrase underline 456-2356
endemphphrase underline after 456-3

emphletter script 4-23
begemphword script 4-2
endemphword script 4-3
lenemphphrase script 3
begemphphrase script 4-2356
endemphphrase script after 4-3

begemph transnote 4-46-126
endemph transnote 4-46-354


emphletter trans1 4-3456-23
begemphword trans1 4-3456-2
endemphword trans1 4-3456-3
lenemphphrase trans1 3
begemphphrase trans1 4-3456-2356
endemphphrase trans1 after 4-3456-3

emphletter trans2 45-3456-23
begemphword trans2 45-3456-2
endemphword trans2 45-3456-3
lenemphphrase trans2 3
begemphphrase trans2 45-3456-2356
endemphphrase trans2 after 45-3456-3

emphletter trans3 456-3456-23
begemphword trans3 456-3456-2
endemphword trans3 456-3456-3
lenemphphrase trans3 3
begemphphrase trans3 456-3456-2356
endemphphrase trans3 after 456-3456-3

emphletter trans4 5-3456-23
begemphword trans4 5-3456-2
endemphword trans4 5-3456-3
lenemphphrase trans4 3
begemphphrase trans4 5-3456-2356
endemphphrase trans4 after 5-3456-3

emphletter trans5 46-3456-23
begemphword trans5 46-3456-2
endemphword trans5 46-3456-3
lenemphphrase trans5 3
begemphphrase trans5 46-3456-2356
endemphphrase trans5 after 46-3456-3

# display/passthrough for unicode braille
include braille-patterns.cti
