Skip to content

Txt2tags writer #6551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 0 additions & 193 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,194 +1 @@
name: CI tests

on:
push:
branches:
- '*'
- '!rc/*'
paths-ignore:
- 'doc/*.md'
- 'MANUAL.txt'
- '*.md'
- 'RELEASE_CHECKLIST'
- 'BUGS'
- 'README.template'
- 'hie.yaml'
- '*.nix'
- 'tools/**'
- 'linux/**'
- 'macos/**'
- 'windows/**'
- 'man/**'
pull_request:
paths-ignore:
- 'doc/*.md'
- 'MANUAL.txt'
- '*.md'
- 'RELEASE_CHECKLIST'
- 'BUGS'
- 'README.template'
- 'hie.yaml'
- '*.nix'
- 'tools/**'
- 'linux/**'
- 'macos/**'
- 'windows/**'
- 'man/**'

permissions:
contents: read

jobs:
linux:

runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
versions:
- ghc: '8.6.5'
cabal: '3.2'
cabalopts: '-f-embed_data_files'
testopts: '--test-option=--hide-successes --test-option=--ansi-tricks=false'
- ghc: '8.8.4'
cabal: '3.2'
cabalopts: '-f-server --enable-benchmarks'
testopts: '--test-option=--hide-successes --test-option=--ansi-tricks=false'
- ghc: '8.10.7'
cabal: '3.2'
cabalopts: ''
testopts: '--test-option=--hide-successes --test-option=--ansi-tricks=false'
- ghc: '9.0.2'
cabal: '3.4'
cabalopts: ''
testopts: '--test-option=--hide-successes --test-option=--ansi-tricks=false'
- ghc: '9.2.3'
cabal: '3.6'
cabalopts: ''
testopts: '--test-option=--hide-successes --test-option=--ansi-tricks=false'
steps:
- uses: actions/checkout@v3

# needed by memory
- name: Install numa
run: sudo apt-get install libnuma-dev

- name: Install cabal/ghc
run: |
ghcup install ghc --set ${{ matrix.versions.ghc }}
ghcup install cabal --set ${{ matrix.versions.cabal }}

# declare/restore cached things

- name: Cache cabal global package db
id: cabal-global
uses: actions/cache@v3
with:
path: |
~/.cabal
key: ${{ runner.os }}-${{ matrix.versions.ghc }}-${{ matrix.versions.cabal }}-cabal-global-${{ secrets.CACHE_VERSION }}

- name: Cache cabal work
id: cabal-local
uses: actions/cache@v3
with:
path: |
dist-newstyle
key: ${{ runner.os }}-${{ matrix.versions.ghc }}-${{ matrix.versions.cabal }}-cabal-local-${{ secrets.CACHE_VERSION }}

- name: Install dependencies
run: |
cabal update
cabal build ${{ matrix.versions.cabalopts }} --dependencies-only --enable-tests --disable-optimization

- name: Build and test
run: |
cabal build ${{ matrix.versions.cabalopts }} --enable-tests --disable-optimization 2>&1 | tee build.log
# fail if warnings in local build
! grep -q ": *[Ww]arning:" build.log || exit 1
cabal test ${{ matrix.versions.cabalopts }} --disable-optimization ${{ matrix.versions.testopts }}

windows:

runs-on: windows-2019

steps:
- uses: actions/checkout@v3

# declare/restore cached things

- name: Cache stack global package db
id: stack-global-package-db
uses: actions/cache@v3
with:
path: |
C:\Users\runneradmin\AppData\Roaming\stack\
key: ${{ runner.os }}-appdata-roaming-stack-${{ hashFiles('stack.yaml') }}

# stack's local package dbs for the project and each package
- name: Cache .stack-work
uses: actions/cache@v1
with:
path: |
.stack-work
key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ secrets.CACHE_VERSION }}
restore-keys: ${{ runner.os }}-stack-work-${{ secrets.CACHE_VERSION }}

- name: Install dependencies
run: |
stack update
stack install happy
stack test --dependencies-only --fast
- name: Build and test
shell: cmd
run: |
stack test --fast --test-arguments="--hide-successes --ansi-tricks=false"

# We no longer run the macos tests, to make CI faster.
# macos:

# runs-on: macos-11
# strategy:
# fail-fast: true
# matrix:
# versions:
# - ghc: '8.8.4'
# cabal: '3.2'

# steps:
# - uses: actions/checkout@v3

# - name: Install cabal/ghc
# run: |
# ghcup install ghc --set ${{ matrix.versions.ghc }}
# ghcup install cabal ${{ matrix.versions.cabal }}

# # declare/restore cached things

# - name: Cache cabal global package db
# id: cabal-global
# uses: actions/cache@v3
# with:
# path: |
# ~/.cabal
# key: ${{ runner.os }}-${{ matrix.versions.ghc }}-${{ matrix.versions.cabal }}-cabal-global-${{ secrets.CACHE_VERSION }}

# - name: Cache cabal work
# id: cabal-local
# uses: actions/cache@v3
# with:
# path: |
# dist-newstyle
# key: ${{ runner.os }}-${{ matrix.versions.ghc }}-${{ matrix.versions.cabal }}-cabal-local-${{ secrets.CACHE_VERSION }}

# - name: Install dependencies
# run: |
# cabal v2-update
# cabal v2-build --dependencies-only --enable-tests --disable-optimization
# - name: Build and test
# run: |
# cabal v2-build --enable-tests --disable-optimization 2>&1 | tee build.log
# # fail if warnings in local build
# ! grep -q ": *[Ww]arning:" build.log || exit 1
# cabal v2-test --disable-optimization --test-option=--hide-successes --test-option=--ansi-tricks=false

51 changes: 1 addition & 50 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Nightly

on:
schedule:
- cron: '53 7 * * *'
- cron: '53 7 1 * *'

permissions:
contents: read
Expand Down Expand Up @@ -41,52 +41,3 @@ jobs:
name: nightly-linux
path: nightly-linux

windows:

runs-on: windows-2019

steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
stack update
stack build --dependencies-only pandoc-cli
- name: Build artifacts
shell: cmd
run: |
for /f %%a in ('powershell -Command "Get-Date -format yyyy-MM-dd"') do set THEDATE=%%a
set ARTIFACTS=%CD%\nightly-windows\pandoc-nightly-windows-%THEDATE%
mkdir %ARTIFACTS%
stack build --flag pandoc-cli:nightly --flag pandoc:embed_data_files pandoc-cli
forfiles /P .\.stack-work\install /M pandoc*.exe /S /C "cmd /C copy @path %%ARTIFACTS%%"
copy COPYRIGHT %ARTIFACTS%
ren %ARTIFACTS%\COPYRIGHT COPYRIGHT.txt
echo Built from %GITHUB_SHA% > %ARTIFACTS%\README.nightly.txt
- uses: actions/upload-artifact@v3
with:
name: nightly-windows
path: nightly-windows

macos:

runs-on: macos-11

steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
stack update
stack build --dependencies-only pandoc-cli
- name: Build artifacts
run: |
export ARTIFACTS=nightly-macos/pandoc-nightly-macos-$(date +%Y-%m-%d)
mkdir -p ${ARTIFACTS}
stack build --flag pandoc:nightly --flag pandoc:embed_data_files pandoc-cli
for f in $(find .stack-work/install -name 'pandoc*' -perm +001 -type f); do cp $f ${ARTIFACTS}/; done
mv ${ARTIFACTS}/pandoc ${ARTIFACTS}/pandoc
cp COPYRIGHT ${ARTIFACTS}/
echo "Built from ${GITHUB_SHA}" > ${ARTIFACTS}/README.nightly.txt
- uses: actions/upload-artifact@v3
with:
name: nightly-macos
path: nightly-macos
1 change: 1 addition & 0 deletions MANUAL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ header when requesting a document from a URL:
- `rtf` ([Rich Text Format])
- `texinfo` ([GNU Texinfo])
- `textile` ([Textile])
- `t2t` ([txt2tags])
- `slideous` ([Slideous] HTML and JavaScript slide show)
- `slidy` ([Slidy] HTML and JavaScript slide show)
- `dzslides` ([DZSlides] HTML5 + JavaScript slide show)
Expand Down
19 changes: 19 additions & 0 deletions data/templates/default.t2t
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$pagetitle$
$author-meta$
$date-meta$



Comment on lines +1 to +6
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why you're getting all that blank space at the beginning. Do you want the 3 blank lines if there's a title? If there's no title block, would it be better to omit them? You can use conditionals like

$if(pagetitle)$
$pagetitle$
$author-meta$
$date-meta$


$endif$

$for(include-before)$
$include-before$

$endfor$
$if(toc)$
__TOC__

$endif$
$body$
$for(include-after)$

$include-after$
$endfor$
4 changes: 4 additions & 0 deletions pandoc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ data-files:
data/templates/default.asciidoctor
data/templates/default.haddock
data/templates/default.textile
data/templates/default.t2t
data/templates/default.org
data/templates/default.epub2
data/templates/default.epub3
Expand Down Expand Up @@ -320,6 +321,7 @@ extra-source-files:
test/tables.texinfo
test/tables.rst
test/tables.rtf
test/tables.t2t
test/tables.txt
test/tables.fb2
test/tables.muse
Expand Down Expand Up @@ -355,6 +357,7 @@ extra-source-files:
test/writer.rst
test/writer.icml
test/writer.rtf
test/writer.t2t
test/writer.tei
test/writer.texinfo
test/writer.fb2
Expand Down Expand Up @@ -597,6 +600,7 @@ library
Text.Pandoc.Writers.Org,
Text.Pandoc.Writers.AsciiDoc,
Text.Pandoc.Writers.Textile,
Text.Pandoc.Writers.Txt2Tags,
Text.Pandoc.Writers.MediaWiki,
Text.Pandoc.Writers.DokuWiki,
Text.Pandoc.Writers.XWiki,
Expand Down
3 changes: 3 additions & 0 deletions src/Text/Pandoc/Writers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module Text.Pandoc.Writers
, writeTEI
, writeTexinfo
, writeTextile
, writeTxt2Tags
, writeXWiki
, writeZimWiki
, getWriter
Expand Down Expand Up @@ -120,6 +121,7 @@ import Text.Pandoc.Writers.RTF
import Text.Pandoc.Writers.TEI
import Text.Pandoc.Writers.Texinfo
import Text.Pandoc.Writers.Textile
import Text.Pandoc.Writers.Txt2Tags
import Text.Pandoc.Writers.XWiki
import Text.Pandoc.Writers.ZimWiki

Expand Down Expand Up @@ -176,6 +178,7 @@ writers = [
,("xwiki" , TextWriter writeXWiki)
,("zimwiki" , TextWriter writeZimWiki)
,("textile" , TextWriter writeTextile)
,("t2t" , TextWriter writeTxt2Tags)
,("rtf" , TextWriter writeRTF)
,("org" , TextWriter writeOrg)
,("asciidoc" , TextWriter writeAsciiDoc)
Expand Down
Loading