Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #183 from alexandrecormier/master
Browse files Browse the repository at this point in the history
Add config option for SyncTeX
  • Loading branch information
thomasjo authored Jun 10, 2016
2 parents 40b682a + fb52a01 commit 404330f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
5 changes: 4 additions & 1 deletion lib/builders/latexmk.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ export default class LatexmkBuilder extends Builder {
'-f',
'-cd',
`-${outputFormat}`,
'-synctex=1',
'-file-line-error'
]

const enableShellEscape = atom.config.get('latex.enableShellEscape')
const enableSynctex = atom.config.get('latex.enableSynctex') !== false
const engineFromMagic = this.getLatexEngineFromMagic(filePath)
const customEngine = atom.config.get('latex.customEngine')
const engine = atom.config.get('latex.engine')

if (enableShellEscape) {
args.push('-shell-escape')
}
if (enableSynctex) {
args.push('-synctex=1')
}

if (engineFromMagic) {
args.push(`-pdflatex="${engineFromMagic}"`)
Expand Down
5 changes: 4 additions & 1 deletion lib/builders/texify.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ export default class TexifyBuilder extends Builder {
const args = [
'--batch',
'--pdf',
'--tex-option="--synctex=1"',
'--tex-option="--interaction=nonstopmode"',
// Set logfile max line length.
'--tex-option="--max-print-line=1000"'
]

const enableShellEscape = atom.config.get('latex.enableShellEscape')
const enableSynctex = atom.config.get('latex.enableSynctex') !== false
const engineFromMagic = this.getLatexEngineFromMagic(filePath)
const customEngine = atom.config.get('latex.customEngine')
const engine = atom.config.get('latex.engine')

if (enableShellEscape) {
args.push('--tex-option=--enable-write18')
}
if (enableSynctex) {
args.push('--tex-option="--synctex=1"')
}

if (engineFromMagic) {
args.push(`--engine="${engineFromMagic}"`)
Expand Down
32 changes: 19 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@
"default": false,
"order": 5
},
"enableSynctex": {
"title": "Enable SyncTeX",
"type": "boolean",
"default": true,
"order": 6
},
"cleanExtensions": {
"type": "array",
"items": {
Expand All @@ -123,13 +129,13 @@
".synctex.gz",
".toc"
],
"order": 6
"order": 7
},
"outputDirectory": {
"description": "All files generated during a build will be redirected here. Leave blank if you want the build output to be stored in the same directory as the TeX document.",
"type": "string",
"default": "",
"order": 7
"order": 8
},
"outputFormat": {
"description": "Output file format. DVI and PS currently only supported for latexmk.",
Expand All @@ -140,72 +146,72 @@
"ps"
],
"default": "pdf",
"order": 8
"order": 9
},
"moveResultToSourceDirectory": {
"title": "Move Result to Source Directory",
"description": "Ensures that the output file produced by a successful build is stored together with the TeX document that produced it.",
"type": "boolean",
"default": true,
"order": 9
"order": 10
},
"buildOnSave": {
"title": "Build on Save",
"description": "Automatically run builds when files are saved.",
"type": "boolean",
"default": false,
"order": 10
"order": 11
},
"openResultAfterBuild": {
"title": "Open Result after Successful Build",
"type": "boolean",
"default": true,
"order": 11
"order": 12
},
"openResultInBackground": {
"title": "Open Result in Background",
"type": "boolean",
"default": true,
"order": 12
"order": 13
},
"alwaysOpenResultInAtom": {
"title": "Always Open Result in Atom",
"description": "Always open result in Atom. Depends on the pdf-view package being installed.",
"type": "boolean",
"default": false,
"order": 13
"order": 14
},
"skimPath": {
"description": "Full application path to Skim (OS X).",
"type": "string",
"default": "/Applications/Skim.app",
"order": 14
"order": 15
},
"sumatraPath": {
"title": "SumatraPDF Path",
"description": "Full application path to SumatraPDF (Windows).",
"type": "string",
"default": "C:\\Program Files (x86)\\SumatraPDF\\SumatraPDF.exe",
"order": 15
"order": 16
},
"okularPath": {
"description": "Full application path to Okular (*nix).",
"type": "string",
"default": "/usr/bin/okular",
"order": 16
"order": 17
},
"viewerPath": {
"title": "Custom PDF Viewer Path",
"description": "Full application path to your PDF viewer. Overrides Skim and SumatraPDF options.",
"type": "string",
"default": "",
"order": 17
"order": 18
},
"useMasterFileSearch": {
"description": "Enables naive search for master/root file when building distributed documents. Note that this does not affect the equivalent *Magic Comments* functionality.",
"type": "boolean",
"default": false,
"order": 18
"order": 19
}
}
}
7 changes: 6 additions & 1 deletion spec/builders/latexmk-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('LatexmkBuilder', () => {
'-f',
'-cd',
'-pdf',
'-synctex=1',
'-file-line-error',
'-synctex=1',
`"${filePath}"`
]
const args = builder.constructArgs(filePath)
Expand All @@ -34,6 +34,11 @@ describe('LatexmkBuilder', () => {
expect(builder.constructArgs(filePath)).toContain('-shell-escape')
})

it('disables synctex according to package config', () => {
atom.config.set('latex.enableSynctex', false)
expect(builder.constructArgs(filePath)).not.toContain('-synctex=1')
})

it('adds -outdir=<path> argument according to package config', () => {
const outdir = 'bar'
const expectedArg = `-outdir="${path.join(fixturesPath, outdir)}"`
Expand Down

0 comments on commit 404330f

Please sign in to comment.