Skip to content

Commit

Permalink
Add the ability to use custom .table files.
Browse files Browse the repository at this point in the history
i.e. You can overwrite our default translation strings for simple
commands such as \pi, or add your own custom commands such as \implies. 

This gives the advantage over the preprocessor of working better with
brltty and routing, as well as allowing us to change existing commands
and add new commands which may not be equivilant to any existing
commands. 
The preprocessor still serves an important purpose though, as I think it
works with more complex commands with arguments, where this will not.
  • Loading branch information
danieldalton10 committed Apr 6, 2013
1 parent 755041d commit 6c7c76b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
15 changes: 14 additions & 1 deletion latex-access.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
;;; A sample configuration for the latex-access project
;;; http://latex-access.sourceforge.net/
;;; To use this config file under emacs move it to ~/.latex-access
;;; To use it for BRLTTY move it to /etc/latex-access.conf
;;; To use it for both jaws and nvda move it to %appdata%/latex-access.conf. For instance,
;;; Type %appdata% into the run dialog, press enter,
;;; And place this file in that directory.
Expand Down Expand Up @@ -35,6 +36,18 @@ capitalisation 6dot

;;; Path pointing to the preprocessor strings.
;;; The preprocessor can be used to add custom commands to the translator which correspond to some standard LaTeX
;;; Default location is ~/.latex-access-preprocessor.strings, but you'll probably want to change this for BRLTTY
;;; Default location is ~/.latex-access-preprocessor.strings
preprocessorfile ~/.latex-access-preprocessor.strings

;;; Custom translation files
;;; These settings should point to a custom translations file to either add non-standard LaTeX commands or to overwrite existing translations.
;;; The format of the custom tables is the standard .table format.
;;; Custom Speech Translations
;;; Uncomment and change path accordingly
;speechfile ~/.latex-access/speech-custom.table
;;; Custom table for the nemeth Braille translations
;nemethfile /etc/latex-access/nemeth-custom.table
;;; Custom file for the UEB translations
;uebfile /etc/latex-access/ueb-custom.table

;;; End of Config
17 changes: 15 additions & 2 deletions latex_access/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# settings.py
# A part of the latex-access project at http://latex-access.sourceforge.net/
# Author: Daniel Dalton <[email protected]>
# Copyright (C) 2011,2012 Daniel Dalton/latex-access Contributors
# Copyright (C) 2011,2012,2013 Daniel Dalton/latex-access Contributors
#
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;
# either version 2 of the License, or (at your option) any later version.
Expand All @@ -18,7 +18,7 @@

globals
# Global settings for latex-access, these are the default values
settings ={"brailledollars":"True","speakdollars":"True","brailletable":"nemeth","capitalisation":"6dot","preprocessorfile":"~/.latex-access-preprocessor.strings"}
settings={"brailledollars":"True","speakdollars":"True","brailletable":"nemeth","capitalisation":"6dot","preprocessorfile":"~/.latex-access-preprocessor.strings", "speechfile":"","nemethfile":"","uebfile":""}

def loadSettings (file):
"""Read settings from file.
Expand Down Expand Up @@ -61,11 +61,24 @@ def activateSettings (instances):
sessions to the values specified in the config file. Note the
activation or deactivation of speech and Braille must be controlled by
each module independently, i.e. not here."""

# points to our custom speech strings file
speechfile =os.path.expanduser(settings["speechfile"])
# Decide what file holds Braille strings based on what table is in use.
if settings["brailletable"].lower() == "ueb":
bfile =os.path.expanduser(settings["uebfile"])
else:
bfile =os.path.expanduser(settings["nemethfile"])

if 'speak' in instances.keys():
instances["speak"].remove_dollars = not booleaniseSetting("speakdollars")
if os.path.exists(speechfile) and os.path.isfile (speechfile):
instances["speak"].load_file(speechfile)
if 'braille' in instances.keys():
instances["braille"].remove_dollars = not booleaniseSetting("brailledollars")
instances["braille"].capitalisation=settings["capitalisation"]
if os.path.exists(bfile) and os.path.isfile (bfile):
instances["braille"].load_file(bfile)
if 'preprocessor' in instances.keys () and os.path.exists(os.path.expanduser (settings["preprocessorfile"])):
instances["preprocessor"].read(os.path.expanduser (settings["preprocessorfile"]))

Expand Down

0 comments on commit 6c7c76b

Please sign in to comment.