From 5435150d39b56bb3364ccec29b45cd0f853b0e00 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 31 Jan 2019 08:34:49 -0800 Subject: [PATCH] doc: don't use sed; fix accidental dedenting of some lists (#961) The sed code was showing an error message, not too precise. Pandoc's lua filters to the rescue! [ci skip] --- Shake.hs | 9 +------ hledger/Hledger/Cli/Commands/Add.txt | 14 +++++------ hledger/Hledger/Cli/Commands/Balance.txt | 32 ++++++++++++------------ hledger/Hledger/Cli/Commands/Print.txt | 16 ++++++------ hledger/Hledger/Cli/Commands/Rewrite.txt | 8 +++--- 5 files changed, 36 insertions(+), 43 deletions(-) diff --git a/Shake.hs b/Shake.hs index 6b5b367ef..d48dbc1f3 100755 --- a/Shake.hs +++ b/Shake.hs @@ -20,7 +20,6 @@ compiling is recommended; run the script in interpreted mode to do that. It requires stack (https://haskell-lang.org/get-started) and auto-installs the packages above. Also, some rules require: -- GNU sed - groff - m4 - makeinfo @@ -86,10 +85,6 @@ towebmd = "-t markdown-smart-fenced_divs --atx-headers" main = do - -- try to ensure we have a modern sed - sed' <- readCreateProcess (shell "which gsed || which sed") "" - let sed = sed' ++ " -E" - -- hledger manual also includes the markdown files from here: let commandsdir = "hledger/Hledger/Cli/Commands" commandmds <- filter (".md" `isSuffixOf`) . map (commandsdir ) <$> S.getDirectoryContents commandsdir @@ -378,9 +373,7 @@ main = do need [src] cmd Shell -- "m4 -P -DHELP -I" commandsdir lib src "|" - pandoc fromsrcmd src "-t plain" - "|" sed "-e" ["'s/^ //'"] - ">" out + pandoc fromsrcmd src "--lua-filter" "tools/pandoc-dedent-code-blocks.lua" "-t plain" ">" out -- MISC diff --git a/hledger/Hledger/Cli/Commands/Add.txt b/hledger/Hledger/Cli/Commands/Add.txt index a90ea38a4..5227faa5d 100644 --- a/hledger/Hledger/Cli/Commands/Add.txt +++ b/hledger/Hledger/Cli/Commands/Add.txt @@ -18,21 +18,21 @@ control-d or control-c to exit. Features: - add tries to provide useful defaults, using the most similar (by -description) recent transaction (filtered by the query, if any) as a -template. + description) recent transaction (filtered by the query, if any) as a + template. - You can also set the initial defaults with command line arguments. - Readline-style edit keys can be used during data entry. - The tab key will auto-complete whenever possible - accounts, -descriptions, dates (yesterday, today, tomorrow). If the input area -is empty, it will insert the default value. + descriptions, dates (yesterday, today, tomorrow). If the input area + is empty, it will insert the default value. - If the journal defines a default commodity, it will be added to any -bare numbers entered. + bare numbers entered. - A parenthesised transaction code may be entered following a date. - Comments and tags may be entered following a description or amount. - If you make a mistake, enter < at any prompt to restart the -transaction. + transaction. - Input prompts are displayed in a different colour when the terminal -supports it. + supports it. Example (see the tutorial for a detailed explanation): diff --git a/hledger/Hledger/Cli/Commands/Balance.txt b/hledger/Hledger/Cli/Commands/Balance.txt index b94e340b2..9d26c710d 100644 --- a/hledger/Hledger/Cli/Commands/Balance.txt +++ b/hledger/Hledger/Cli/Commands/Balance.txt @@ -97,10 +97,10 @@ data fields interpolated like so: - MAX truncates at this width (optional) - FIELDNAME must be enclosed in parentheses, and can be one of: -- depth_spacer - a number of spaces equal to the account's depth, - or if MIN is specified, MIN * depth spaces. -- account - the account's name -- total - the account's balance/posted total, right justified + - depth_spacer - a number of spaces equal to the account's depth, + or if MIN is specified, MIN * depth spaces. + - account - the account's name + - total - the account's balance/posted total, right justified Also, FMT can begin with an optional prefix to control how multi-commodity amounts are rendered: @@ -117,12 +117,12 @@ Some example formats: - %(total) - the account's total - %-20.20(account) - the account's name, left justified, padded to 20 -characters and clipped at 20 characters + characters and clipped at 20 characters - %,%-50(account) %25(total) - account name padded to 50 characters, -total padded to 20 characters, with multiple commodities rendered on -one line + total padded to 20 characters, with multiple commodities rendered on + one line - %20(total) %2(depth_spacer)%-(account) - the default format for the -single-column balance report + single-column balance report Colour support @@ -169,8 +169,8 @@ There are three types of multicolumn balance report, showing different information: 1. By default: each column shows the sum of postings in that period, ie -the account's change of balance in that period. This is useful eg -for a monthly income statement: + the account's change of balance in that period. This is useful eg + for a monthly income statement: $ hledger balance --quarterly income expenses -E Balance changes in 2008: @@ -185,8 +185,8 @@ for a monthly income statement: || $-1 $1 0 0 2. With --cumulative: each column shows the ending balance for that -period, accumulating the changes across periods, starting from 0 at -the report start date: + period, accumulating the changes across periods, starting from 0 at + the report start date: $ hledger balance --quarterly income expenses -E --cumulative Ending balances (cumulative) in 2008: @@ -201,10 +201,10 @@ the report start date: || $-1 0 0 0 3. With --historical/-H: each column shows the actual historical ending -balance for that period, accumulating the changes across periods, -starting from the actual balance at the report start date. This is -useful eg for a multi-period balance sheet, and when you are showing -only the data after a certain start date: + balance for that period, accumulating the changes across periods, + starting from the actual balance at the report start date. This is + useful eg for a multi-period balance sheet, and when you are showing + only the data after a certain start date: $ hledger balance ^assets ^liabilities --quarterly --historical --begin 2008/4/1 Ending balances (historical) in 2008/04/01-2008/12/31: diff --git a/hledger/Hledger/Cli/Commands/Print.txt b/hledger/Hledger/Cli/Commands/Print.txt index db13e447c..3120e0ea7 100644 --- a/hledger/Hledger/Cli/Commands/Print.txt +++ b/hledger/Hledger/Cli/Commands/Print.txt @@ -83,14 +83,14 @@ $ hledger print -Ocsv "5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","","" - There is one CSV record per posting, with the parent transaction's -fields repeated. + fields repeated. - The "txnidx" (transaction index) field shows which postings belong -to the same transaction. (This number might change if transactions -are reordered within the file, files are parsed/included in a -different order, etc.) + to the same transaction. (This number might change if transactions + are reordered within the file, files are parsed/included in a + different order, etc.) - The amount is separated into "commodity" (the symbol) and "amount" -(numeric quantity) fields. + (numeric quantity) fields. - The numeric amount is repeated in either the "credit" or "debit" -column, for convenience. (Those names are not accurate in the -accounting sense; it just puts negative amounts under credit and -zero or greater amounts under debit.) + column, for convenience. (Those names are not accurate in the + accounting sense; it just puts negative amounts under credit and + zero or greater amounts under debit.) diff --git a/hledger/Hledger/Cli/Commands/Rewrite.txt b/hledger/Hledger/Cli/Commands/Rewrite.txt index 5bd638eb6..ff9ea6f16 100644 --- a/hledger/Hledger/Cli/Commands/Rewrite.txt +++ b/hledger/Hledger/Cli/Commands/Rewrite.txt @@ -118,11 +118,11 @@ This command predates print --auto, and currently does much the same thing, but with these differences: - with multiple files, rewrite lets rules in any file affect all other -files. print --auto uses standard directive scoping; rules affect -only child files. + files. print --auto uses standard directive scoping; rules affect + only child files. - rewrite's query limits which transactions can be rewritten; all are -printed. print --auto's query limits which transactions are printed. + printed. print --auto's query limits which transactions are printed. - rewrite applies rules specified on command line or in the journal. -print --auto applies rules specified in the journal. + print --auto applies rules specified in the journal.