diff --git a/CHANGES.md b/CHANGES.md
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,88 @@
 User-visible changes in the hledger command line tool and library.
 
 
+# 1.18 2020-06-07
+
+## General
+
+- The --forecast flag now takes an optional argument
+  (--forecast=PERIODICEXPR), allowing periodic transactions to
+  start/end on any date and to overlap recorded transactions.
+  (#835, #1236) (Dmitry Astapov)
+
+- An upper case file extension no longer confuses file format
+  detection. (#1225)
+
+- In the commands list, redundant source scripts are now hidden
+  properly when a corresponding .com/.exe file exists. (#1225)
+
+- We now show `..` instead of `-` to indicate date ranges, eg in
+  report titles, to stand out more from hyphenated dates. 
+  
+- Period expressions (eg in -p, date:, and periodic rules) now accept
+  `to`, `until`, `-`, or `..` as synonyms.
+
+- When parsing amounts, whitespace between sign and number is now allowed.
+
+- A clearer error message is shown on encountering a malformed regular
+  expression.
+
+## commands
+
+- commands allowing different output formats now list their supported
+  formats accurately in --help (#689)
+
+- commands allowing JSON output now actually produce JSON (#689)
+
+- bal, bs: show .. (not ,,) in report titles, like other reports
+
+## journal format
+
+- We now also infer market prices from transactions, like Ledger.
+  See https://hledger.org/hledger.html#market-prices (#1239). 
+  
+  Upgrade note: this means value reports (-V, -X etc.) can give
+  different output compared to hledger 1.17. If needed, you can
+  prevent this by adding a P directive declaring the old price, on or
+  after the date of the transaction causing the issue.
+
+- The include directive now accepts a file format prefix, like the
+  -f/--file option. This works with glob patterns too, applying the
+  prefix to each path. This can be useful when included files don't
+  have the standard file extension, eg:
+
+      include timedot:2020*.md
+
+- We now accept (and ignore) Ledger-style lot dates
+  (`[DATE]`) and four lot price forms (`{PRICE}`, `{{PRICE}}`,
+  `{=PRICE}`, `{{=PRICE}}`), anywhere after the posting amount but
+  before any balance assertion.
+
+- We now accept Ledger-style parenthesised "virtual posting
+  costs" (`(@)`, `(@@)`). In hledger these are equivalent to the
+  unparenthesised form.
+
+- The unbalanced transaction error message is clearer, especially when
+  postings all have the same sign, and is split into multiple lines
+  for readability.
+
+## csv format
+
+- You can now generate up to 99 postings in a transaction. (Vladimir Sorokin)
+
+- You can now generate postings with an explicit 0 amount. (#1112)
+
+- For each posting, when both numbered and unnumbered amount
+  assignments are active (eg: both `amount` and `amount1`), we ignore
+  the unnumbered ones. This makes it easier to override old `amount`
+  rules.
+  
+- Fix a 1.17.1 regression involving amount-in/amount-out. (#1226)
+
+- Assigning too many non-zero or zero values to a posting amount now
+  gives a clearer error. (#1226)
+
+
 # 1.17.1.1 2020-03-19
 
 - update bounds after some belated hledger-* version bumps
@@ -22,7 +104,7 @@
 - require newer Decimal, math-functions libs to ensure consistent
   rounding behaviour, even when built with old GHCs/snapshots. 
   hledger uses banker's rounding (rounds to nearest even number, eg
-  0.5 with with zero decimal places is "0").
+  0.5 displayed with zero decimal places is "0").
 
 # 1.17 2020-03-01
 
diff --git a/Hledger/Cli/CliOptions.hs b/Hledger/Cli/CliOptions.hs
--- a/Hledger/Cli/CliOptions.hs
+++ b/Hledger/Cli/CliOptions.hs
@@ -15,7 +15,7 @@
   hiddenflags,
   inputflags,
   reportflags,
-  outputflags,
+  -- outputflags,
   outputFormatFlag,
   outputFileFlag,
   generalflagsgroup1,
@@ -35,6 +35,7 @@
   CliOpts(..),
   defcliopts,
   getHledgerCliOpts,
+  getHledgerCliOpts',
   rawOptsToCliOpts,
   checkCliOpts,
   outputFormats,
@@ -180,8 +181,12 @@
 
   -- generated postings/transactions
  ,flagNone ["auto"]          (setboolopt "auto") "apply automated posting rules to modify transactions"
- ,flagNone ["forecast"]      (setboolopt "forecast") "generate future transactions from periodic transaction rules, for the next 6 months or till report end date. In hledger-ui, also make ordinary future transactions visible."
-
+ ,flagOpt "" ["forecast"]    (\s opts -> Right $ setopt "forecast" s opts) "PERIODEXP" 
+  (unlines
+   [ "Generate periodic transactions (from periodic transaction rules). By default these begin after the latest recorded transaction, and end 6 months from today, or at the report end date."
+   , "Also, in hledger-ui, make future transactions visible."
+   , "Note that = (and not a space) is required before PERIODEXP if you wish to supply it."
+   ])
  ]
 
 -- | Common flags that are accepted but not shown in --help,
@@ -192,10 +197,19 @@
  ]
 
 -- | Common output-related flags: --output-file, --output-format...
-outputflags = [outputFormatFlag, outputFileFlag]
-outputFormatFlag = flagReq  ["output-format","O"] (\s opts -> Right $ setopt "output-format" s opts) "FMT" "select the output format. Supported formats:\ntxt, csv, html."
-outputFileFlag   = flagReq  ["output-file","o"]   (\s opts -> Right $ setopt "output-file" s opts) "FILE" "write output to FILE. A file extension matching one of the above formats selects that format."
 
+-- outputflags = [outputFormatFlag, outputFileFlag]
+
+outputFormatFlag :: [String] -> Flag RawOpts
+outputFormatFlag fmts = flagReq
+  ["output-format","O"] (\s opts -> Right $ setopt "output-format" s opts) "FMT"
+  ("select the output format. Supported formats:\n" ++ intercalate ", " fmts ++ ".")
+
+outputFileFlag :: Flag RawOpts
+outputFileFlag = flagReq
+  ["output-file","o"] (\s opts -> Right $ setopt "output-file" s opts) "FILE"
+  "write output to FILE. A file extension matching one of the above formats selects that format."
+
 argsFlag :: FlagHelp -> Arg RawOpts
 argsFlag desc = flagArg (\s opts -> Right $ setopt "args" s opts) desc
 
@@ -470,9 +484,8 @@
 -- Empty lines in the pre/postamble are removed by cmdargs;
 -- add a space character to preserve them.
 --
-getHledgerCliOpts :: Mode RawOpts -> IO CliOpts
-getHledgerCliOpts mode' = do
-  args' <- getArgs >>= expandArgsAt
+getHledgerCliOpts' :: Mode RawOpts -> [String] -> IO CliOpts
+getHledgerCliOpts' mode' args' = do
   let rawopts = either usageError id $ process mode' args'
   opts <- rawOptsToCliOpts rawopts
   debugArgs args' opts
@@ -499,6 +512,11 @@
         d <- getCurrentDay
         putStrLn $ "search query: " ++ show (queryFromOpts d $ reportopts_ opts)
 
+getHledgerCliOpts :: Mode RawOpts -> IO CliOpts
+getHledgerCliOpts mode' = do
+  args' <- getArgs >>= expandArgsAt
+  getHledgerCliOpts' mode' args' 
+
 -- CliOpts accessors
 
 -- | Get the (tilde-expanded, absolute) journal file path from
@@ -649,8 +667,8 @@
 stripPrognamePrefix = drop (length progname + 1)
 
 dropRedundantSourceVersion [f,g]
-  | takeExtension f `elem` compiledExts = [f]
-  | takeExtension g `elem` compiledExts = [g]
+  | map toLower (takeExtension f) `elem` compiledExts = [f]
+  | map toLower (takeExtension g) `elem` compiledExts = [g]
 dropRedundantSourceVersion fs = fs
 
 compiledExts = ["",".com",".exe"]
diff --git a/Hledger/Cli/Commands/Add.hs b/Hledger/Cli/Commands/Add.hs
--- a/Hledger/Cli/Commands/Add.hs
+++ b/Hledger/Cli/Commands/Add.hs
@@ -339,7 +339,7 @@
       def = case (esArgs, mhistoricalp, followedhistoricalsofar) of
               (d:_,_,_)                                             -> d
               (_,Just hp,True)                                      -> showamt $ pamount hp
-              _  | pnum > 1 && not (isZeroMixedAmount balancingamt) -> showamt balancingamtfirstcommodity
+              _  | pnum > 1 && not (mixedAmountLooksZero balancingamt) -> showamt balancingamtfirstcommodity
               _                                                     -> ""
   retryMsg "A valid hledger amount is required. Eg: 1, $2, 3 EUR, \"4 red apples\"." $
    parser parseAmountAndComment $
diff --git a/Hledger/Cli/Commands/Balance.hs b/Hledger/Cli/Commands/Balance.hs
--- a/Hledger/Cli/Commands/Balance.hs
+++ b/Hledger/Cli/Commands/Balance.hs
@@ -253,7 +253,6 @@
  ,tests_Balance
 ) where
 
-import Data.Aeson (toJSON)
 import Data.List
 import Data.Maybe
 --import qualified Data.Map as Map
@@ -294,8 +293,9 @@
    ,flagNone ["invert"] (setboolopt "invert") "display all amounts with reversed sign"
    ,flagNone ["transpose"] (setboolopt "transpose") "transpose rows and columns"
    ,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total"
+   ,outputFormatFlag ["txt","html","csv","json"]
+   ,outputFileFlag
    ]
-   ++ outputflags
   )
   [generalflagsgroup1]
   hiddenflags
@@ -319,18 +319,18 @@
                 assrt          = not $ ignore_assertions_ $ inputopts_ opts
             render = case fmt of
               "txt"  -> budgetReportAsText ropts
-              "json" -> (++"\n") . pshow . toJSON  -- XXX pshow for pretty output, but it may generate some junk
+              "json" -> (++"\n") . TL.unpack . toJsonText
               _      -> const $ error' $ unsupportedOutputFormatError fmt
         writeOutput opts $ render budgetreport
 
       else
         if multiperiod then do  -- multi period balance report
-          let report = multiBalanceReport ropts (queryFromOpts d ropts) j
+          let report = multiBalanceReport d ropts j
               render = case fmt of
                 "txt"  -> multiBalanceReportAsText ropts
                 "csv"  -> (++"\n") . printCSV . multiBalanceReportAsCsv ropts
                 "html" -> (++"\n") . TL.unpack . L.renderText . multiBalanceReportAsHtml ropts
-                "json" -> (++"\n") . pshow . toJSON  -- XXX pshow for pretty output, but it may generate some junk
+                "json" -> (++"\n") . TL.unpack . toJsonText
                 _      -> const $ error' $ unsupportedOutputFormatError fmt
           writeOutput opts $ render report
 
@@ -345,7 +345,7 @@
               render = case fmt of
                 "txt"  -> balanceReportAsText
                 "csv"  -> \ropts r -> (++ "\n") $ printCSV $ balanceReportAsCsv ropts r
-                "json" -> const $ (++"\n") . pshow . toJSON  -- XXX pshow for pretty output, but it may generate some junk
+                "json" -> const $ (++"\n") . TL.unpack . toJsonText
                 _      -> const $ error' $ unsupportedOutputFormatError fmt
           writeOutput opts $ render ropts report
 
diff --git a/Hledger/Cli/Commands/Balance.txt b/Hledger/Cli/Commands/Balance.txt
--- a/Hledger/Cli/Commands/Balance.txt
+++ b/Hledger/Cli/Commands/Balance.txt
@@ -351,13 +351,14 @@
 ----------------------++----------------------------------------------------
                       ||      0 [              0]       0 [              0] 
 
-Note this is different from a normal balance report in several ways:
+This is different from a normal balance report in several ways:
 
 -   Only accounts with budget goals during the report period are shown,
     by default.
 
--   In each column, in square brackets after the actual amount, budgeted
-    amounts are shown, along with the percentage of budget used.
+-   In each column, in square brackets after the actual amount, budget
+    goal amounts are shown, and the actual/goal percentage. (Note:
+    budget goals should be in the same commodity as the actual amount.)
 
 -   All parent accounts are always shown, even in flat mode. Eg assets,
     assets:bank, and expenses above.
diff --git a/Hledger/Cli/Commands/Print.hs b/Hledger/Cli/Commands/Print.hs
--- a/Hledger/Cli/Commands/Print.hs
+++ b/Hledger/Cli/Commands/Print.hs
@@ -15,10 +15,10 @@
 )
 where
 
-import Data.Aeson (toJSON)
 import Data.Maybe (isJust)
 import Data.Text (Text)
 import qualified Data.Text as T
+import qualified Data.Text.Lazy as TL
 import System.Console.CmdArgs.Explicit
 import Hledger.Read.CsvReader (CSV, printCSV)
 
@@ -37,7 +37,9 @@
     "show all amounts explicitly"
   ,flagNone ["new"] (setboolopt "new")
     "show only newer-dated transactions added in each file since last run"
-  ] ++ outputflags)
+  ,outputFormatFlag ["txt","csv","json"]
+  ,outputFileFlag
+  ])
   [generalflagsgroup1]
   hiddenflags
   ([], Just $ argsFlag "[QUERY]")
@@ -57,7 +59,7 @@
       render = case fmt of
         "txt"  -> entriesReportAsText opts
         "csv"  -> (++"\n") . printCSV . entriesReportAsCsv
-        "json" -> (++"\n") . pshow . toJSON  -- XXX pshow for pretty output, but it may generate some junk
+        "json" -> (++"\n") . TL.unpack . toJsonText
         _      -> const $ error' $ unsupportedOutputFormatError fmt
   writeOutput opts $ render $ entriesReport ropts q j
 
diff --git a/Hledger/Cli/Commands/Register.hs b/Hledger/Cli/Commands/Register.hs
--- a/Hledger/Cli/Commands/Register.hs
+++ b/Hledger/Cli/Commands/Register.hs
@@ -18,11 +18,11 @@
  ,tests_Register
 ) where
 
-import Data.Aeson (toJSON)
 import Data.List
 import Data.Maybe
 -- import Data.Text (Text)
 import qualified Data.Text as T
+import qualified Data.Text.Lazy as TL
 import System.Console.CmdArgs.Explicit
 import Hledger.Read.CsvReader (CSV, CsvRecord, printCSV)
 
@@ -49,7 +49,9 @@
 #endif
       ++ " or $COLUMNS). -wN,M sets description width as well."
      )
-  ] ++ outputflags)
+  ,outputFormatFlag ["txt","csv","json"]
+  ,outputFileFlag
+  ])
   [generalflagsgroup1]
   hiddenflags
   ([], Just $ argsFlag "[QUERY]")
@@ -61,7 +63,7 @@
   let fmt = outputFormatFromOpts opts
       render | fmt=="txt"  = postingsReportAsText
              | fmt=="csv"  = const ((++"\n") . printCSV . postingsReportAsCsv)
-             | fmt=="json" = const ((++"\n") . pshow . toJSON)  -- XXX pshow for pretty output, but it may generate some junk
+             | fmt=="json" = const ((++"\n") . TL.unpack . toJsonText)
              | otherwise   = const $ error' $ unsupportedOutputFormatError fmt
   writeOutput opts $ render opts $ postingsReport ropts (queryFromOpts d ropts) j
 
diff --git a/Hledger/Cli/Commands/Roi.hs b/Hledger/Cli/Commands/Roi.hs
--- a/Hledger/Cli/Commands/Roi.hs
+++ b/Hledger/Cli/Commands/Roi.hs
@@ -234,7 +234,7 @@
 
 unMix :: MixedAmount -> Quantity
 unMix a =
-  case (normaliseMixedAmount $ costOfMixedAmount a) of
+  case (normaliseMixedAmount $ mixedAmountCost a) of
     (Mixed [a]) -> aquantity a
     _ -> error "MixedAmount failed to normalize"
 
diff --git a/Hledger/Cli/CompoundBalanceCommand.hs b/Hledger/Cli/CompoundBalanceCommand.hs
--- a/Hledger/Cli/CompoundBalanceCommand.hs
+++ b/Hledger/Cli/CompoundBalanceCommand.hs
@@ -13,7 +13,6 @@
  ,compoundBalanceCommand
 ) where
 
-import Data.Aeson (toJSON)
 import Data.List (foldl')
 import Data.Maybe
 import qualified Data.Text as TS
@@ -107,7 +106,7 @@
     ,flagNone ["pretty-tables"] (setboolopt "pretty-tables") "use unicode when displaying tables"
     ,flagNone ["sort-amount","S"] (setboolopt "sort-amount") "sort by amount instead of account code/name"
     ,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total"
-    ,outputFormatFlag
+    ,outputFormatFlag ["txt","html","csv","json"]
     ,outputFileFlag
     ]
     [generalflagsgroup1]
@@ -240,7 +239,7 @@
         "txt"  -> compoundBalanceReportAsText ropts' cbr
         "csv"  -> printCSV (compoundBalanceReportAsCsv ropts cbr) ++ "\n"
         "html" -> (++"\n") $ TL.unpack $ L.renderText $ compoundBalanceReportAsHtml ropts cbr
-        "json" -> (++"\n") $ pshow $ toJSON cbr  -- XXX pshow for pretty output, but it may generate some junk
+        "json" -> (++"\n") $ TL.unpack $ toJsonText cbr
         _      -> error' $ unsupportedOutputFormatError fmt
 
 -- | Summarise one or more (inclusive) end dates, in a way that's
@@ -249,7 +248,7 @@
 showEndDates :: [Day] -> String
 showEndDates es = case es of
   -- cf showPeriod
-  (e:_:_) -> showdate e ++ ",," ++ showdate (last es)
+  (e:_:_) -> showdate e ++ ".." ++ showdate (last es)
   [e]     -> showdate e
   []      -> ""
   where
@@ -273,11 +272,11 @@
             nonzeroaccounts =
               dbg1 "nonzeroaccounts" $
               mapMaybe (\(PeriodicReportRow act _ amts _ _) ->
-                            if not (all isZeroMixedAmount amts) then Just act else Nothing) rows
+                            if not (all mixedAmountLooksZero amts) then Just act else Nothing) rows
             rows' = filter (not . emptyRow) rows
               where
                 emptyRow (PeriodicReportRow act _ amts _ _) =
-                  all isZeroMixedAmount amts && not (any (act `isAccountNamePrefixOf`) nonzeroaccounts)
+                  all mixedAmountLooksZero amts && not (any (act `isAccountNamePrefixOf`) nonzeroaccounts)
 
 -- | Render a compound balance report as plain text suitable for console output.
 {- Eg:
diff --git a/Hledger/Cli/Utils.hs b/Hledger/Cli/Utils.hs
--- a/Hledger/Cli/Utils.hs
+++ b/Hledger/Cli/Utils.hs
@@ -60,7 +60,7 @@
 
 -- | Standard error message for a bad output format specified with -O/-o.
 unsupportedOutputFormatError :: String -> String
-unsupportedOutputFormatError fmt = "Sorry, output format \""++fmt++"\" is unrecognised or not yet implemented for this report."
+unsupportedOutputFormatError fmt = "Sorry, output format \""++fmt++"\" is unrecognised or not yet implemented for this report or report mode."
 
 -- | Parse the user's specified journal file(s) as a Journal, maybe apply some
 -- transformations according to options, and run a hledger command with it.
@@ -114,18 +114,22 @@
 -- from today if unspecified.
 --
 journalAddForecast :: CliOpts -> Journal -> IO Journal
-journalAddForecast opts@CliOpts{inputopts_=iopts, reportopts_=ropts} j = do
+journalAddForecast CliOpts{inputopts_=iopts, reportopts_=ropts} j = do
   today <- getCurrentDay
 
   -- "They can start no earlier than: the day following the latest normal transaction in the journal (or today if there are none)."
   let mjournalend   = dbg2 "journalEndDate" $ journalEndDate False j  -- ignore secondary dates
-      forecaststart = dbg2 "forecaststart" $ fromMaybe today mjournalend
+      forecastbeginDefault = dbg2 "forecastbeginDefault" $ fromMaybe today mjournalend
 
   -- "They end on or before the specified report end date, or 180 days from today if unspecified."
   mspecifiedend <-  snd . dbg2 "specifieddates" <$> specifiedStartEndDates ropts
-  let forecastend = dbg2 "forecastend" $ fromMaybe (addDays 180 today) mspecifiedend
-
-  let forecastspan = DateSpan (Just forecaststart) (Just forecastend)
+  let forecastendDefault = dbg2 "forecastendDefault" $ fromMaybe (addDays 180 today) mspecifiedend
+      
+  let forecastspan = dbg2 "forecastspan" $
+        spanDefaultsFrom
+          (fromMaybe nulldatespan $ dbg2 "forecastspan flag" $ forecast_ ropts)
+          (DateSpan (Just forecastbeginDefault) (Just forecastendDefault))
+          
       forecasttxns =
         [ txnTieKnot t | pt <- jperiodictxns j
                        , t <- runPeriodicTransaction pt forecastspan
@@ -135,12 +139,12 @@
       forecasttxns' = (if auto_ iopts then modifyTransactions (jtxnmodifiers j) else id) forecasttxns
 
   return $
-    if forecast_ ropts
-      then journalBalanceTransactions' opts j{ jtxns = concat [jtxns j, forecasttxns'] }
-      else j
+    case forecast_ ropts of
+      Just _  -> journalBalanceTransactions' iopts j{ jtxns = concat [jtxns j, forecasttxns'] }
+      Nothing -> j
   where
-    journalBalanceTransactions' opts j =
-      let assrt = not . ignore_assertions_ $ inputopts_ opts
+    journalBalanceTransactions' iopts j =
+      let assrt = not . ignore_assertions_ $ iopts
       in
        either error' id $ journalBalanceTransactions assrt j
 
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,129 +1,9 @@
-#  hledger
-
-## lightweight, portable, dependable accounting tools
-
-hledger is a computer program for easily tracking money, time, or other commodities,
-on unix, mac and windows (and web-capable mobile devices, to some extent).
-
-It is first a command-line tool, but there are also terminal and
-web interfaces, and a Haskell library
-(http://hackage.haskell.org/package/hledger-lib) for building your own
-programs and scripts (hledger is written in Haskell).  hledger was
-inspired by and is largely compatible with Ledger.  hledger is free
-software available under the GNU General Public License v3+.
-
-hledger aims to help both computer experts and regular folks
-to gain clarity and control in their finances and time management,
-but currently it is a bit more suited to techies.
-I use it every day to:
-
--   track spending and income
--   see time reports by day/week/month/project
--   get accurate numbers for client billing and tax filing
--   track invoices
-
-Though limited in features, hledger is lightweight, usable and reliable.
-For some, it is a simpler, less distracting, more future-proof alternative to Quicken or GnuCash.
-
-For more, see http://hledger.org.
-
-## Support
-
-### Backers
-Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/hledger#backer)]
-
-<a href="https://opencollective.com/hledger/backer/0/website" target="_blank"><img src="https://opencollective.com/hledger/backer/0/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/1/website" target="_blank"><img src="https://opencollective.com/hledger/backer/1/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/2/website" target="_blank"><img src="https://opencollective.com/hledger/backer/2/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/3/website" target="_blank"><img src="https://opencollective.com/hledger/backer/3/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/4/website" target="_blank"><img src="https://opencollective.com/hledger/backer/4/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/5/website" target="_blank"><img src="https://opencollective.com/hledger/backer/5/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/6/website" target="_blank"><img src="https://opencollective.com/hledger/backer/6/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/7/website" target="_blank"><img src="https://opencollective.com/hledger/backer/7/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/8/website" target="_blank"><img src="https://opencollective.com/hledger/backer/8/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/9/website" target="_blank"><img src="https://opencollective.com/hledger/backer/9/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/10/website" target="_blank"><img src="https://opencollective.com/hledger/backer/10/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/11/website" target="_blank"><img src="https://opencollective.com/hledger/backer/11/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/12/website" target="_blank"><img src="https://opencollective.com/hledger/backer/12/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/13/website" target="_blank"><img src="https://opencollective.com/hledger/backer/13/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/14/website" target="_blank"><img src="https://opencollective.com/hledger/backer/14/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/15/website" target="_blank"><img src="https://opencollective.com/hledger/backer/15/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/16/website" target="_blank"><img src="https://opencollective.com/hledger/backer/16/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/17/website" target="_blank"><img src="https://opencollective.com/hledger/backer/17/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/18/website" target="_blank"><img src="https://opencollective.com/hledger/backer/18/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/19/website" target="_blank"><img src="https://opencollective.com/hledger/backer/19/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/20/website" target="_blank"><img src="https://opencollective.com/hledger/backer/20/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/21/website" target="_blank"><img src="https://opencollective.com/hledger/backer/21/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/22/website" target="_blank"><img src="https://opencollective.com/hledger/backer/22/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/23/website" target="_blank"><img src="https://opencollective.com/hledger/backer/23/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/24/website" target="_blank"><img src="https://opencollective.com/hledger/backer/24/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/25/website" target="_blank"><img src="https://opencollective.com/hledger/backer/25/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/26/website" target="_blank"><img src="https://opencollective.com/hledger/backer/26/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/27/website" target="_blank"><img src="https://opencollective.com/hledger/backer/27/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/28/website" target="_blank"><img src="https://opencollective.com/hledger/backer/28/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/backer/29/website" target="_blank"><img src="https://opencollective.com/hledger/backer/29/avatar.svg"></a>
-
-### Sponsors
-Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/hledger#sponsor)]
-
-<a href="https://opencollective.com/hledger/sponsor/0/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/0/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/1/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/1/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/2/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/2/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/3/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/3/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/4/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/4/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/5/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/5/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/6/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/6/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/7/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/7/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/8/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/8/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/9/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/9/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/10/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/10/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/11/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/11/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/12/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/12/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/13/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/13/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/14/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/14/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/15/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/15/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/16/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/16/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/17/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/17/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/18/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/18/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/19/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/19/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/20/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/20/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/21/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/21/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/22/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/22/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/23/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/23/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/24/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/24/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/25/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/25/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/26/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/26/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/27/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/27/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/28/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/28/avatar.svg"></a>
-<a href="https://opencollective.com/hledger/sponsor/29/website" target="_blank"><img src="https://opencollective.com/hledger/sponsor/29/avatar.svg"></a>
-
-[![license](https://img.shields.io/badge/license-GPLv3+-brightgreen.svg)](http://www.gnu.org/licenses/gpl.html)
-
-[![hledger CI](https://github.com/simonmichael/hledger/workflows/hledger%20CI/badge.svg)](https://github.com/simonmichael/hledger/actions)
-<!-- [![Build Status](https://travis-ci.org/simonmichael/hledger.svg?branch=master)](https://travis-ci.org/simonmichael/hledger/builds) -->
-<!-- [![Build Status](https://ci.appveyor.com/api/projects/status/5vejw0w5n5igdr42?svg=true)](https://ci.appveyor.com/project/simonmichael/hledger/history) -->
-
-[![on hackage](https://img.shields.io/hackage/v/hledger.svg?label=hackage&colorB=green)](http://hackage.haskell.org/package/hledger)
-<br>
-[![](https://img.shields.io/hackage-deps/v/hledger-lib.svg?label=hledger-lib+bounds)](http://packdeps.haskellers.com/feed?needle=hledger-lib)
-[![](https://img.shields.io/hackage-deps/v/hledger.svg?label=hledger+bounds)](http://packdeps.haskellers.com/feed?needle=hledger)
-<br>
-[![](https://img.shields.io/hackage-deps/v/hledger-ui.svg?label=hledger-ui+bounds)](http://packdeps.haskellers.com/feed?needle=hledger-ui)
-[![](https://img.shields.io/hackage-deps/v/hledger-web.svg?label=hledger-web+bounds)](http://packdeps.haskellers.com/feed?needle=hledger-web)
-
-[![](https://repology.org/badge/version-for-repo/stackage_lts/hledger.svg)](https://repology.org/metapackage/hledger)
-[![](https://repology.org/badge/version-for-repo/stackage_nighly/hledger.svg)](https://repology.org/metapackage/hledger)
-<!-- [![on stackage lts](http://stackage.org/package/hledger/badge/lts)](http://stackage.org/lts/package/hledger) -->
-<!-- [![on stackage nightly](http://stackage.org/package/hledger/badge/nightly)](http://stackage.org/nightly/package/hledger) -->
+# hledger
 
-<!-- [![github
-release](https://img.shields.io/github/release/simonmichael/hledger.svg?label=github+release)](https://github.com/simonmichael/hledger/releases)
---> <!-- [![github latest release
-downloads](https://img.shields.io/github/downloads/simonmichael/hledger/latest/total.svg?label=github+downloads)](https://github.com/simonmichael/hledger/releases)
---> <!-- [![gratipay](https://img.shields.io/gratipay/hledger.svg)]()
--->
+The command-line interface for the hledger accounting system.
+Its basic function is to read a plain text file describing
+financial transactions and produce useful reports.
 
-[![OpenCollective](https://opencollective.com/hledger/backers/badge.svg)](#backers)
-[![OpenCollective](https://opencollective.com/hledger/sponsors/badge.svg)](#sponsors)
-[![bountysource](https://api.bountysource.com/badge/team?team_id=75979&style=bounties_received)](https://github.com/simonmichael/hledger/issues?q=label:bounty)
-[![github issues](https://img.shields.io/github/issues/simonmichael/hledger.svg)](http://bugs.hledger.org)
+See also:
+the [project README](https://hledger.org/README.html)
+and [home page](https://hledger.org).
diff --git a/embeddedfiles/hledger-ui.1 b/embeddedfiles/hledger-ui.1
--- a/embeddedfiles/hledger-ui.1
+++ b/embeddedfiles/hledger-ui.1
@@ -1,5 +1,5 @@
 
-.TH "hledger-ui" "1" "March 2020" "hledger-ui 1.17.1.1" "hledger User Manuals"
+.TH "hledger-ui" "1" "June 2020" "hledger-ui 1.18" "hledger User Manuals"
 
 
 
diff --git a/embeddedfiles/hledger-ui.info b/embeddedfiles/hledger-ui.info
--- a/embeddedfiles/hledger-ui.info
+++ b/embeddedfiles/hledger-ui.info
@@ -3,8 +3,8 @@
 
 File: hledger-ui.info,  Node: Top,  Next: OPTIONS,  Up: (dir)
 
-hledger-ui(1) hledger-ui 1.17.1.1
-*********************************
+hledger-ui(1) hledger-ui 1.18
+*****************************
 
 hledger-ui - terminal interface for the hledger accounting tool
 
@@ -499,26 +499,26 @@
 
 Tag Table:
 Node: Top71
-Node: OPTIONS1478
-Ref: #options1575
-Node: KEYS5006
-Ref: #keys5101
-Node: SCREENS9377
-Ref: #screens9482
-Node: Accounts screen9572
-Ref: #accounts-screen9700
-Node: Register screen11916
-Ref: #register-screen12071
-Node: Transaction screen14068
-Ref: #transaction-screen14226
-Node: Error screen15096
-Ref: #error-screen15218
-Node: ENVIRONMENT15462
-Ref: #environment15576
-Node: FILES16383
-Ref: #files16482
-Node: BUGS16695
-Ref: #bugs16772
+Node: OPTIONS1470
+Ref: #options1567
+Node: KEYS4998
+Ref: #keys5093
+Node: SCREENS9369
+Ref: #screens9474
+Node: Accounts screen9564
+Ref: #accounts-screen9692
+Node: Register screen11908
+Ref: #register-screen12063
+Node: Transaction screen14060
+Ref: #transaction-screen14218
+Node: Error screen15088
+Ref: #error-screen15210
+Node: ENVIRONMENT15454
+Ref: #environment15568
+Node: FILES16375
+Ref: #files16474
+Node: BUGS16687
+Ref: #bugs16764
 
 End Tag Table
 
diff --git a/embeddedfiles/hledger-ui.txt b/embeddedfiles/hledger-ui.txt
--- a/embeddedfiles/hledger-ui.txt
+++ b/embeddedfiles/hledger-ui.txt
@@ -441,4 +441,4 @@
 
 
 
-hledger-ui 1.17.1.1               March 2020                     hledger-ui(1)
+hledger-ui 1.18                    June 2020                     hledger-ui(1)
diff --git a/embeddedfiles/hledger-web.1 b/embeddedfiles/hledger-web.1
--- a/embeddedfiles/hledger-web.1
+++ b/embeddedfiles/hledger-web.1
@@ -1,5 +1,5 @@
 
-.TH "hledger-web" "1" "March 2020" "hledger-web 1.17.1" "hledger User Manuals"
+.TH "hledger-web" "1" "June 2020" "hledger-web 1.18" "hledger User Manuals"
 
 
 
@@ -316,60 +316,215 @@
 that both machine clocks are roughly in step.)
 .SH JSON API
 .PP
-In addition to the web UI, hledger-web provides some API routes that
-serve JSON in response to GET requests.
-(And when started with \f[C]--serve-api\f[R], it provides only these
-routes.):
+In addition to the web UI, hledger-web also serves a JSON API that can
+be used to get data or add new transactions.
+If you want the JSON API only, you can use the \f[C]--serve-api\f[R]
+flag.
+Eg:
 .IP
 .nf
 \f[C]
+$ hledger-web -f examples/sample.journal --serve-api
+\&...
+\f[R]
+.fi
+.PP
+You can get JSON data from these routes:
+.IP
+.nf
+\f[C]
 /accountnames
 /transactions
 /prices
 /commodities
 /accounts
-/accounttransactions/#AccountName
+/accounttransactions/ACCOUNTNAME
 \f[R]
 .fi
 .PP
-Also, you can append a new transaction to the journal by sending a PUT
-request to \f[C]/add\f[R] (hledger-web only).
-As with the web UI\[aq]s add form, hledger-web must be started with the
-\f[C]add\f[R] capability for this (enabled by default).
+Eg, all account names in the journal (similar to the accounts command).
+(hledger-web\[aq]s JSON does not include newlines, here we use python to
+prettify it):
+.IP
+.nf
+\f[C]
+$ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool
+[
+    \[dq]assets\[dq],
+    \[dq]assets:bank\[dq],
+    \[dq]assets:bank:checking\[dq],
+    \[dq]assets:bank:saving\[dq],
+    \[dq]assets:cash\[dq],
+    \[dq]expenses\[dq],
+    \[dq]expenses:food\[dq],
+    \[dq]expenses:supplies\[dq],
+    \[dq]income\[dq],
+    \[dq]income:gifts\[dq],
+    \[dq]income:salary\[dq],
+    \[dq]liabilities\[dq],
+    \[dq]liabilities:debts\[dq]
+]
+\f[R]
+.fi
 .PP
-The payload should be a valid hledger transaction as JSON, similar to
-what you get from \f[C]/transactions\f[R] or
-\f[C]/accounttransactions\f[R].
+Or all transactions:
+.IP
+.nf
+\f[C]
+$ curl -s http://127.0.0.1:5000/transactions | python -m json.tool
+[
+    {
+        \[dq]tcode\[dq]: \[dq]\[dq],
+        \[dq]tcomment\[dq]: \[dq]\[dq],
+        \[dq]tdate\[dq]: \[dq]2008-01-01\[dq],
+        \[dq]tdate2\[dq]: null,
+        \[dq]tdescription\[dq]: \[dq]income\[dq],
+        \[dq]tindex\[dq]: 1,
+        \[dq]tpostings\[dq]: [
+            {
+                \[dq]paccount\[dq]: \[dq]assets:bank:checking\[dq],
+                \[dq]pamount\[dq]: [
+                    {
+                        \[dq]acommodity\[dq]: \[dq]$\[dq],
+                        \[dq]aismultiplier\[dq]: false,
+                        \[dq]aprice\[dq]: null,
+\&...
+\f[R]
+.fi
 .PP
-Another way to generate test data is with the
-\f[C]readJsonFile\f[R]/\f[C]writeJsonFile\f[R] helpers in
-Hledger.Web.Json, which can write or read most of hledger\[aq]s data
-types to or from a file.
-Eg here we write the first transaction of a sample journal:
+Most of the JSON corresponds to hledger\[aq]s data types; for details of
+what the fields mean, see the Hledger.Data.Json haddock docs and click
+on the various data types, eg Transaction.
+And for a higher level understanding, see the journal manual.
+.PP
+In some cases there is outer JSON corresponding to a \[dq]Report\[dq]
+type.
+To understand that, go to the Hledger.Web.Handler.MiscR haddock and look
+at the source for the appropriate handler to see what it returns.
+Eg for \f[C]/accounttransactions\f[R] it\[aq]s getAccounttransactionsR,
+returning a \[dq]\f[C]accountTransactionsReport ...\f[R]\[dq].
+Looking up the haddock for that we can see that /accounttransactions
+returns an AccountTransactionsReport, which consists of a report title
+and a list of AccountTransactionsReportItem (etc).
+.PP
+You can add a new transaction to the journal with a PUT request to
+\f[C]/add\f[R], if hledger-web was started with the \f[C]add\f[R]
+capability (enabled by default).
+The payload must be the full, exact JSON representation of a hledger
+transaction (partial data won\[aq]t do).
+You can get sample JSON from hledger-web\[aq]s \f[C]/transactions\f[R]
+or \f[C]/accounttransactions\f[R], or you can export it with
+hledger-lib, eg like so:
 .IP
 .nf
 \f[C]
-$ make ghci-web
->>> :m +*Hledger.Web.Json
+\&.../hledger$ stack ghci hledger-lib
 >>> writeJsonFile \[dq]txn.json\[dq] (head $ jtxns samplejournal)
 >>> :q
-$ python -m json.tool <txn.json >txn.pretty.json  # optional: make human-readable
 \f[R]
 .fi
 .PP
-(sample output & discussion)
-.PP
-And here\[aq]s how to test adding that with curl:
+Here\[aq]s how it looks as of hledger-1.17 (remember, this JSON
+corresponds to hledger\[aq]s Transaction and related data types):
 .IP
 .nf
 \f[C]
-$ curl -s http://127.0.0.1:5000/add -X PUT -H \[aq]Content-Type: application/json\[aq] --data-binary \[at]txn.pretty.json; echo
+{
+    \[dq]tcomment\[dq]: \[dq]\[dq],
+    \[dq]tpostings\[dq]: [
+        {
+            \[dq]pbalanceassertion\[dq]: null,
+            \[dq]pstatus\[dq]: \[dq]Unmarked\[dq],
+            \[dq]pamount\[dq]: [
+                {
+                    \[dq]aprice\[dq]: null,
+                    \[dq]acommodity\[dq]: \[dq]$\[dq],
+                    \[dq]aquantity\[dq]: {
+                        \[dq]floatingPoint\[dq]: 1,
+                        \[dq]decimalPlaces\[dq]: 10,
+                        \[dq]decimalMantissa\[dq]: 10000000000
+                    },
+                    \[dq]aismultiplier\[dq]: false,
+                    \[dq]astyle\[dq]: {
+                        \[dq]ascommodityside\[dq]: \[dq]L\[dq],
+                        \[dq]asdigitgroups\[dq]: null,
+                        \[dq]ascommodityspaced\[dq]: false,
+                        \[dq]asprecision\[dq]: 2,
+                        \[dq]asdecimalpoint\[dq]: \[dq].\[dq]
+                    }
+                }
+            ],
+            \[dq]ptransaction_\[dq]: \[dq]1\[dq],
+            \[dq]paccount\[dq]: \[dq]assets:bank:checking\[dq],
+            \[dq]pdate\[dq]: null,
+            \[dq]ptype\[dq]: \[dq]RegularPosting\[dq],
+            \[dq]pcomment\[dq]: \[dq]\[dq],
+            \[dq]pdate2\[dq]: null,
+            \[dq]ptags\[dq]: [],
+            \[dq]poriginal\[dq]: null
+        },
+        {
+            \[dq]pbalanceassertion\[dq]: null,
+            \[dq]pstatus\[dq]: \[dq]Unmarked\[dq],
+            \[dq]pamount\[dq]: [
+                {
+                    \[dq]aprice\[dq]: null,
+                    \[dq]acommodity\[dq]: \[dq]$\[dq],
+                    \[dq]aquantity\[dq]: {
+                        \[dq]floatingPoint\[dq]: -1,
+                        \[dq]decimalPlaces\[dq]: 10,
+                        \[dq]decimalMantissa\[dq]: -10000000000
+                    },
+                    \[dq]aismultiplier\[dq]: false,
+                    \[dq]astyle\[dq]: {
+                        \[dq]ascommodityside\[dq]: \[dq]L\[dq],
+                        \[dq]asdigitgroups\[dq]: null,
+                        \[dq]ascommodityspaced\[dq]: false,
+                        \[dq]asprecision\[dq]: 2,
+                        \[dq]asdecimalpoint\[dq]: \[dq].\[dq]
+                    }
+                }
+            ],
+            \[dq]ptransaction_\[dq]: \[dq]1\[dq],
+            \[dq]paccount\[dq]: \[dq]income:salary\[dq],
+            \[dq]pdate\[dq]: null,
+            \[dq]ptype\[dq]: \[dq]RegularPosting\[dq],
+            \[dq]pcomment\[dq]: \[dq]\[dq],
+            \[dq]pdate2\[dq]: null,
+            \[dq]ptags\[dq]: [],
+            \[dq]poriginal\[dq]: null
+        }
+    ],
+    \[dq]ttags\[dq]: [],
+    \[dq]tsourcepos\[dq]: {
+        \[dq]tag\[dq]: \[dq]JournalSourcePos\[dq],
+        \[dq]contents\[dq]: [
+            \[dq]\[dq],
+            [
+                1,
+                1
+            ]
+        ]
+    },
+    \[dq]tdate\[dq]: \[dq]2008-01-01\[dq],
+    \[dq]tcode\[dq]: \[dq]\[dq],
+    \[dq]tindex\[dq]: 1,
+    \[dq]tprecedingcomment\[dq]: \[dq]\[dq],
+    \[dq]tdate2\[dq]: null,
+    \[dq]tdescription\[dq]: \[dq]income\[dq],
+    \[dq]tstatus\[dq]: \[dq]Unmarked\[dq]
+}
 \f[R]
 .fi
 .PP
-By default, both the server-side HTML UI and the JSON API are served.
-Running with \f[C]--serve-api\f[R] disables the former, useful if you
-only want to serve the API.
+And here\[aq]s how to test adding it with curl.
+This should add a new entry to your journal:
+.IP
+.nf
+\f[C]
+$ curl http://127.0.0.1:5000/add -X PUT -H \[aq]Content-Type: application/json\[aq] --data-binary \[at]txn.json
+\f[R]
+.fi
 .SH ENVIRONMENT
 .PP
 \f[B]LEDGER_FILE\f[R] The journal file path when not specified with
diff --git a/embeddedfiles/hledger-web.info b/embeddedfiles/hledger-web.info
--- a/embeddedfiles/hledger-web.info
+++ b/embeddedfiles/hledger-web.info
@@ -3,8 +3,8 @@
 
 File: hledger-web.info,  Node: Top,  Next: OPTIONS,  Up: (dir)
 
-hledger-web(1) hledger-web 1.17.1
-*********************************
+hledger-web(1) hledger-web 1.18
+*******************************
 
 hledger-web - web interface for the hledger accounting tool
 
@@ -330,45 +330,182 @@
 5 JSON API
 **********
 
-In addition to the web UI, hledger-web provides some API routes that
-serve JSON in response to GET requests.  (And when started with
-'--serve-api', it provides only these routes.):
+In addition to the web UI, hledger-web also serves a JSON API that can
+be used to get data or add new transactions.  If you want the JSON API
+only, you can use the '--serve-api' flag.  Eg:
 
+$ hledger-web -f examples/sample.journal --serve-api
+...
+
+   You can get JSON data from these routes:
+
 /accountnames
 /transactions
 /prices
 /commodities
 /accounts
-/accounttransactions/#AccountName
+/accounttransactions/ACCOUNTNAME
 
-   Also, you can append a new transaction to the journal by sending a
-PUT request to '/add' (hledger-web only).  As with the web UI's add
-form, hledger-web must be started with the 'add' capability for this
-(enabled by default).
+   Eg, all account names in the journal (similar to the accounts
+command).  (hledger-web's JSON does not include newlines, here we use
+python to prettify it):
 
-   The payload should be a valid hledger transaction as JSON, similar to
-what you get from '/transactions' or '/accounttransactions'.
+$ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool
+[
+    "assets",
+    "assets:bank",
+    "assets:bank:checking",
+    "assets:bank:saving",
+    "assets:cash",
+    "expenses",
+    "expenses:food",
+    "expenses:supplies",
+    "income",
+    "income:gifts",
+    "income:salary",
+    "liabilities",
+    "liabilities:debts"
+]
 
-   Another way to generate test data is with the
-'readJsonFile'/'writeJsonFile' helpers in Hledger.Web.Json, which can
-write or read most of hledger's data types to or from a file.  Eg here
-we write the first transaction of a sample journal:
+   Or all transactions:
 
-$ make ghci-web
->>> :m +*Hledger.Web.Json
+$ curl -s http://127.0.0.1:5000/transactions | python -m json.tool
+[
+    {
+        "tcode": "",
+        "tcomment": "",
+        "tdate": "2008-01-01",
+        "tdate2": null,
+        "tdescription": "income",
+        "tindex": 1,
+        "tpostings": [
+            {
+                "paccount": "assets:bank:checking",
+                "pamount": [
+                    {
+                        "acommodity": "$",
+                        "aismultiplier": false,
+                        "aprice": null,
+...
+
+   Most of the JSON corresponds to hledger's data types; for details of
+what the fields mean, see the Hledger.Data.Json haddock docs and click
+on the various data types, eg Transaction.  And for a higher level
+understanding, see the journal manual.
+
+   In some cases there is outer JSON corresponding to a "Report" type.
+To understand that, go to the Hledger.Web.Handler.MiscR haddock and look
+at the source for the appropriate handler to see what it returns.  Eg
+for '/accounttransactions' it's getAccounttransactionsR, returning a
+"'accountTransactionsReport ...'".  Looking up the haddock for that we
+can see that /accounttransactions returns an AccountTransactionsReport,
+which consists of a report title and a list of
+AccountTransactionsReportItem (etc).
+
+   You can add a new transaction to the journal with a PUT request to
+'/add', if hledger-web was started with the 'add' capability (enabled by
+default).  The payload must be the full, exact JSON representation of a
+hledger transaction (partial data won't do).  You can get sample JSON
+from hledger-web's '/transactions' or '/accounttransactions', or you can
+export it with hledger-lib, eg like so:
+
+.../hledger$ stack ghci hledger-lib
 >>> writeJsonFile "txn.json" (head $ jtxns samplejournal)
 >>> :q
-$ python -m json.tool <txn.json >txn.pretty.json  # optional: make human-readable
 
-   (sample output & discussion)
+   Here's how it looks as of hledger-1.17 (remember, this JSON
+corresponds to hledger's Transaction and related data types):
 
-   And here's how to test adding that with curl:
+{
+    "tcomment": "",
+    "tpostings": [
+        {
+            "pbalanceassertion": null,
+            "pstatus": "Unmarked",
+            "pamount": [
+                {
+                    "aprice": null,
+                    "acommodity": "$",
+                    "aquantity": {
+                        "floatingPoint": 1,
+                        "decimalPlaces": 10,
+                        "decimalMantissa": 10000000000
+                    },
+                    "aismultiplier": false,
+                    "astyle": {
+                        "ascommodityside": "L",
+                        "asdigitgroups": null,
+                        "ascommodityspaced": false,
+                        "asprecision": 2,
+                        "asdecimalpoint": "."
+                    }
+                }
+            ],
+            "ptransaction_": "1",
+            "paccount": "assets:bank:checking",
+            "pdate": null,
+            "ptype": "RegularPosting",
+            "pcomment": "",
+            "pdate2": null,
+            "ptags": [],
+            "poriginal": null
+        },
+        {
+            "pbalanceassertion": null,
+            "pstatus": "Unmarked",
+            "pamount": [
+                {
+                    "aprice": null,
+                    "acommodity": "$",
+                    "aquantity": {
+                        "floatingPoint": -1,
+                        "decimalPlaces": 10,
+                        "decimalMantissa": -10000000000
+                    },
+                    "aismultiplier": false,
+                    "astyle": {
+                        "ascommodityside": "L",
+                        "asdigitgroups": null,
+                        "ascommodityspaced": false,
+                        "asprecision": 2,
+                        "asdecimalpoint": "."
+                    }
+                }
+            ],
+            "ptransaction_": "1",
+            "paccount": "income:salary",
+            "pdate": null,
+            "ptype": "RegularPosting",
+            "pcomment": "",
+            "pdate2": null,
+            "ptags": [],
+            "poriginal": null
+        }
+    ],
+    "ttags": [],
+    "tsourcepos": {
+        "tag": "JournalSourcePos",
+        "contents": [
+            "",
+            [
+                1,
+                1
+            ]
+        ]
+    },
+    "tdate": "2008-01-01",
+    "tcode": "",
+    "tindex": 1,
+    "tprecedingcomment": "",
+    "tdate2": null,
+    "tdescription": "income",
+    "tstatus": "Unmarked"
+}
 
-$ curl -s http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.pretty.json; echo
+   And here's how to test adding it with curl.  This should add a new
+entry to your journal:
 
-   By default, both the server-side HTML UI and the JSON API are served.
-Running with '--serve-api' disables the former, useful if you only want
-to serve the API.
+$ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json
 
 
 File: hledger-web.info,  Node: ENVIRONMENT,  Next: FILES,  Prev: JSON API,  Up: Top
@@ -427,22 +564,22 @@
 
 Tag Table:
 Node: Top72
-Node: OPTIONS1750
-Ref: #options1855
-Node: PERMISSIONS8199
-Ref: #permissions8338
-Node: EDITING UPLOADING DOWNLOADING9550
-Ref: #editing-uploading-downloading9731
-Node: RELOADING10565
-Ref: #reloading10699
-Node: JSON API11132
-Ref: #json-api11246
-Node: ENVIRONMENT12684
-Ref: #environment12800
-Node: FILES13533
-Ref: #files13633
-Node: BUGS13846
-Ref: #bugs13924
+Node: OPTIONS1746
+Ref: #options1851
+Node: PERMISSIONS8195
+Ref: #permissions8334
+Node: EDITING UPLOADING DOWNLOADING9546
+Ref: #editing-uploading-downloading9727
+Node: RELOADING10561
+Ref: #reloading10695
+Node: JSON API11128
+Ref: #json-api11242
+Node: ENVIRONMENT16723
+Ref: #environment16839
+Node: FILES17572
+Ref: #files17672
+Node: BUGS17885
+Ref: #bugs17963
 
 End Tag Table
 
diff --git a/embeddedfiles/hledger-web.txt b/embeddedfiles/hledger-web.txt
--- a/embeddedfiles/hledger-web.txt
+++ b/embeddedfiles/hledger-web.txt
@@ -289,45 +289,182 @@
        that both machine clocks are roughly in step.)
 
 JSON API
-       In addition to the web UI, hledger-web provides some  API  routes  that
-       serve  JSON  in  response  to  GET  requests.   (And  when started with
-       --serve-api, it provides only these routes.):
+       In addition to the web UI, hledger-web also serves a JSON API that  can
+       be  used to get data or add new transactions.  If you want the JSON API
+       only, you can use the --serve-api flag.  Eg:
 
+              $ hledger-web -f examples/sample.journal --serve-api
+              ...
+
+       You can get JSON data from these routes:
+
               /accountnames
               /transactions
               /prices
               /commodities
               /accounts
-              /accounttransactions/#AccountName
+              /accounttransactions/ACCOUNTNAME
 
-       Also, you can append a new transaction to the journal by sending a  PUT
-       request  to  /add  (hledger-web  only).  As with the web UI's add form,
-       hledger-web must be started with the add capability for  this  (enabled
-       by default).
+       Eg, all account names in the journal (similar to the accounts command).
+       (hledger-web's  JSON  does  not include newlines, here we use python to
+       prettify it):
 
-       The  payload  should be a valid hledger transaction as JSON, similar to
-       what you get from /transactions or /accounttransactions.
+              $ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool
+              [
+                  "assets",
+                  "assets:bank",
+                  "assets:bank:checking",
+                  "assets:bank:saving",
+                  "assets:cash",
+                  "expenses",
+                  "expenses:food",
+                  "expenses:supplies",
+                  "income",
+                  "income:gifts",
+                  "income:salary",
+                  "liabilities",
+                  "liabilities:debts"
+              ]
 
-       Another way to generate test data is with  the  readJsonFile/writeJson-
-       File  helpers  in  Hledger.Web.Json,  which  can  write or read most of
-       hledger's data types to or from a file.  Eg here  we  write  the  first
-       transaction of a sample journal:
+       Or all transactions:
 
-              $ make ghci-web
-              >>> :m +*Hledger.Web.Json
+              $ curl -s http://127.0.0.1:5000/transactions | python -m json.tool
+              [
+                  {
+                      "tcode": "",
+                      "tcomment": "",
+                      "tdate": "2008-01-01",
+                      "tdate2": null,
+                      "tdescription": "income",
+                      "tindex": 1,
+                      "tpostings": [
+                          {
+                              "paccount": "assets:bank:checking",
+                              "pamount": [
+                                  {
+                                      "acommodity": "$",
+                                      "aismultiplier": false,
+                                      "aprice": null,
+              ...
+
+       Most of the JSON corresponds to hledger's data types;  for  details  of
+       what  the fields mean, see the Hledger.Data.Json haddock docs and click
+       on the various data types, eg Transaction.  And for a higher level  un-
+       derstanding, see the journal manual.
+
+       In some cases there is outer JSON corresponding to a "Report" type.  To
+       understand that, go to the Hledger.Web.Handler.MiscR haddock  and  look
+       at  the  source for the appropriate handler to see what it returns.  Eg
+       for /accounttransactions it's getAccounttransactionsR, returning a "ac-
+       countTransactionsReport  ...".   Looking up the haddock for that we can
+       see that  /accounttransactions  returns  an  AccountTransactionsReport,
+       which  consists  of a report title and a list of AccountTransactionsRe-
+       portItem (etc).
+
+       You can add a new transaction to the journal  with  a  PUT  request  to
+       /add,  if  hledger-web  was started with the add capability (enabled by
+       default).  The payload must be the full, exact JSON representation of a
+       hledger  transaction  (partial data won't do).  You can get sample JSON
+       from hledger-web's /transactions or /accounttransactions,  or  you  can
+       export it with hledger-lib, eg like so:
+
+              .../hledger$ stack ghci hledger-lib
               >>> writeJsonFile "txn.json" (head $ jtxns samplejournal)
               >>> :q
-              $ python -m json.tool <txn.json >txn.pretty.json  # optional: make human-readable
 
-       (sample output & discussion)
+       Here's how it looks as of hledger-1.17 (remember, this JSON corresponds
+       to hledger's Transaction and related data types):
 
-       And here's how to test adding that with curl:
+              {
+                  "tcomment": "",
+                  "tpostings": [
+                      {
+                          "pbalanceassertion": null,
+                          "pstatus": "Unmarked",
+                          "pamount": [
+                              {
+                                  "aprice": null,
+                                  "acommodity": "$",
+                                  "aquantity": {
+                                      "floatingPoint": 1,
+                                      "decimalPlaces": 10,
+                                      "decimalMantissa": 10000000000
+                                  },
+                                  "aismultiplier": false,
+                                  "astyle": {
+                                      "ascommodityside": "L",
+                                      "asdigitgroups": null,
+                                      "ascommodityspaced": false,
+                                      "asprecision": 2,
+                                      "asdecimalpoint": "."
+                                  }
+                              }
+                          ],
+                          "ptransaction_": "1",
+                          "paccount": "assets:bank:checking",
+                          "pdate": null,
+                          "ptype": "RegularPosting",
+                          "pcomment": "",
+                          "pdate2": null,
+                          "ptags": [],
+                          "poriginal": null
+                      },
+                      {
+                          "pbalanceassertion": null,
+                          "pstatus": "Unmarked",
+                          "pamount": [
+                              {
+                                  "aprice": null,
+                                  "acommodity": "$",
+                                  "aquantity": {
+                                      "floatingPoint": -1,
+                                      "decimalPlaces": 10,
+                                      "decimalMantissa": -10000000000
+                                  },
+                                  "aismultiplier": false,
+                                  "astyle": {
+                                      "ascommodityside": "L",
+                                      "asdigitgroups": null,
+                                      "ascommodityspaced": false,
+                                      "asprecision": 2,
+                                      "asdecimalpoint": "."
+                                  }
+                              }
+                          ],
+                          "ptransaction_": "1",
+                          "paccount": "income:salary",
+                          "pdate": null,
+                          "ptype": "RegularPosting",
+                          "pcomment": "",
+                          "pdate2": null,
+                          "ptags": [],
+                          "poriginal": null
+                      }
+                  ],
+                  "ttags": [],
+                  "tsourcepos": {
+                      "tag": "JournalSourcePos",
+                      "contents": [
+                          "",
+                          [
+                              1,
+                              1
+                          ]
+                      ]
+                  },
+                  "tdate": "2008-01-01",
+                  "tcode": "",
+                  "tindex": 1,
+                  "tprecedingcomment": "",
+                  "tdate2": null,
+                  "tdescription": "income",
+                  "tstatus": "Unmarked"
+              }
 
-              $ curl -s http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.pretty.json; echo
+       And here's how to test adding it with curl.  This should add a new  en-
+       try to your journal:
 
-       By  default,  both the server-side HTML UI and the JSON API are served.
-       Running with --serve-api disables the former, useful if you  only  want
-       to serve the API.
+              $ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json
 
 ENVIRONMENT
        LEDGER_FILE The journal file path when not specified with -f.  Default:
@@ -392,4 +529,4 @@
 
 
 
-hledger-web 1.17.1                March 2020                    hledger-web(1)
+hledger-web 1.18                   June 2020                    hledger-web(1)
diff --git a/embeddedfiles/hledger.1 b/embeddedfiles/hledger.1
--- a/embeddedfiles/hledger.1
+++ b/embeddedfiles/hledger.1
@@ -1,6 +1,6 @@
 .\"t
 
-.TH "hledger" "1" "March 2020" "hledger 1.17.1.1" "hledger User Manuals"
+.TH "hledger" "1" "June 2020" "hledger 1.18" "hledger User Manuals"
 
 
 
@@ -1101,15 +1101,6 @@
 mostly in
 https://github.com/simonmichael/hledger/blob/master/hledger-lib/Hledger/Data/Types.hs.
 .IP \[bu] 2
-The JSON output from hledger commands is essentially the same as the
-JSON served by hledger-web\[aq]s JSON API, but pretty printed, using
-line breaks and indentation.
-Our pretty printer has the ability to elide data in certain cases -
-rendering non-strings as if they were strings, or displaying
-\[dq]FOO..\[dq] instead of FOO\[aq]s full details.
-This should never happen in hledger\[aq]s JSON output; if you see
-otherwise, please report as a bug.
-.IP \[bu] 2
 hledger represents quantities as Decimal values storing up to 255
 significant digits, eg for repeating decimals.
 Such numbers can arise in practice (from automatically-calculated
@@ -1136,20 +1127,28 @@
 \f[C]--alias /REGEX/=REPLACEMENT\f[R]
 .PP
 hledger\[aq]s regular expressions come from the regex-tdfa library.
-In general they:
-.IP \[bu] 2
-are case insensitive
-.IP \[bu] 2
-are infix matching (do not need to match the entire thing being matched)
-.IP \[bu] 2
-are POSIX extended regular expressions
-.IP \[bu] 2
-also support GNU word boundaries (\[rs]<, \[rs]>, \[rs]b, \[rs]B)
-.IP \[bu] 2
-and parenthesised capturing groups and numeric backreferences in
-replacement strings
-.IP \[bu] 2
-do not support mode modifiers like (?s)
+If they\[aq]re not doing what you expect, it\[aq]s important to know
+exactly what they support:
+.IP "1." 3
+they are case insensitive
+.IP "2." 3
+they are infix matching (they do not need to match the entire thing
+being matched)
+.IP "3." 3
+they are POSIX ERE (extended regular expressions)
+.IP "4." 3
+they also support GNU word boundaries (\f[C]\[rs]b\f[R],
+\f[C]\[rs]B\f[R], \f[C]\[rs]<\f[R], \f[C]\[rs]>\f[R])
+.IP "5." 3
+they do not support backreferences; if you write \f[C]\[rs]1\f[R], it
+will match the digit \f[C]1\f[R].
+Except when doing text replacement, eg in account aliases, where
+backreferences can be used in the replacement string to reference
+capturing groups in the search regexp.
+.IP "6." 3
+they do not support mode modifiers (\f[C](?s)\f[R]), character classes
+(\f[C]\[rs]w\f[R], \f[C]\[rs]d\f[R]), or anything else not mentioned
+above.
 .PP
 Some things to note:
 .IP \[bu] 2
@@ -1290,7 +1289,7 @@
 .PP
 .TS
 tab(@);
-lw(11.9n) lw(58.1n).
+lw(12.4n) lw(57.6n).
 T{
 \f[C]-b 2016/3/17\f[R]
 T}@T{
@@ -1313,16 +1312,17 @@
 all transactions in the current month
 T}
 T{
-\f[C]date:2016/3/17-\f[R]
+\f[C]date:2016/3/17..\f[R]
 T}@T{
-the above written as queries instead
+the above written as queries instead (\f[C]..\f[R] can also be replaced
+with \f[C]-\f[R])
 T}
 T{
-\f[C]date:-12/1\f[R]
+\f[C]date:..12/1\f[R]
 T}@T{
 T}
 T{
-\f[C]date:thismonth-\f[R]
+\f[C]date:thismonth..\f[R]
 T}@T{
 T}
 T{
@@ -1354,7 +1354,7 @@
 .PP
 Keywords like \[dq]from\[dq] and \[dq]to\[dq] are optional, and so are
 the spaces, as long as you don\[aq]t run two dates together.
-\[dq]to\[dq] can also be written as \[dq]-\[dq].
+\[dq]to\[dq] can also be written as \[dq]..\[dq] or \[dq]-\[dq].
 These are equivalent to the above:
 .PP
 .TS
@@ -1367,7 +1367,7 @@
 \f[C]-p2009/1/1to2009/4/1\f[R]
 T}
 T{
-\f[C]-p2009/1/1-2009/4/1\f[R]
+\f[C]-p2009/1/1..2009/4/1\f[R]
 T}
 .TE
 .PP
@@ -1594,8 +1594,7 @@
 in the account tree, down to level N.
 Use this when you want a summary with less detail.
 This flag has the same effect as a \f[C]depth:\f[R] query argument (so
-\f[C]-2\f[R], \f[C]--depth=2\f[R] or \f[C]depth:2\f[R] are basically
-equivalent).
+\f[C]-2\f[R], \f[C]--depth=2\f[R] or \f[C]depth:2\f[R] are equivalent).
 .SS Pivoting
 .PP
 Normally hledger sums amounts, and organizes them in a hierarchy, based
@@ -1671,31 +1670,48 @@
 \f[R]
 .fi
 .SS Valuation
+.PP
+hledger can show cost reports, where amounts are converted to their cost
+or sale amount at transaction time; or value reports, where amounts are
+converted to their market value in another currency/commodity at a
+specified date (using market prices inferred from your transactions, or
+declared with P directives).
+.PP
+We call this \[dq]valuation\[dq], and it is controlled by the
+\f[C]--value=VALUATIONTYPE[,COMMODITY]\f[R] option.
+It can get a little involved, so we cover all the details below.
+But most of the time, all you need to do is use these simpler flags
+instead:
+.IP \[bu] 2
+\f[C]-B\f[R] to convert to cost/sale amount, or
+.IP \[bu] 2
+\f[C]-V\f[R] to convert to market value in your base currency.
+Or occasionally,
+.IP \[bu] 2
+\f[C]-X COMMODITY\f[R] to convert to market value in some other
+currency.
 .SS -B: Cost
 .PP
-The \f[C]-B/--cost\f[R] flag converts amounts to their cost (or selling
-price) at transaction time, if they have a transaction price specified.
-This flag is equivalent to \f[C]--value=cost\f[R], described below.
-.SS -V: Market value
+The \f[C]-B/--cost\f[R] flag converts amounts to their cost or sale
+amount at transaction time, if they have a transaction price specified.
+(It is equivalent to \f[C]--value=cost\f[R].)
+.SS -V: Value
 .PP
-The \f[C]-V/--market\f[R] flag converts reported amounts to their market
-value in a default valuation commodity, using the market prices in
-effect on a default valuation date.
-For single period reports, the valuation date is today (equivalent to
-\f[C]--value=now\f[R]); for multiperiod reports, it is the last day of
-each subperiod (equivalent to \f[C]--value=end\f[R]).
+The \f[C]-V/--market\f[R] flag converts reported amounts to market value
+in their \f[I]default valuation commodity\f[R], using the market prices
+in effect on a \f[I]default valuation date\f[R].
+(More on these below.)
 .PP
 The default valuation commodity is the one referenced in the latest
 applicable market price dated on or before the valuation date.
-If most of your P declarations lead to a single home currency, this will
-usually be what you want.
-(To specify the commodity, see -X below.)
+Typically your P declarations or currency exchange transactions
+reference a single base currency, and -V will pick that.
 .PP
-Note that in hledger, market prices are always declared explicitly with
-P directives; we do not infer them from transaction prices as Ledger
-does.
+The default valuation date is today for single period reports
+(equivalent to \f[C]--value=now\f[R]), or the last day of each subperiod
+for multiperiod reports (equivalent to \f[C]--value=end\f[R]).
 .PP
-Here\[aq]s a quick example of -V:
+An example:
 .IP
 .nf
 \f[C]
@@ -1743,8 +1759,31 @@
 .PP
 The \f[C]-X/--exchange\f[R] option is like \f[C]-V\f[R], except it
 specifies the target commodity you would like to convert to.
-It is equivalent to \f[C]--value=now,COMM\f[R] or
-\f[C]--value=end,COMM\f[R].
+(It is equivalent to \f[C]--value=now,COMM\f[R] or
+\f[C]--value=end,COMM\f[R].)
+.SS Market prices
+.PP
+To convert a commodity A to commodity B, hledger looks for a suitable
+market price (exchange rate) in the following ways, in this order of
+preference:
+.IP "1." 3
+a \f[I]declared market price\f[R] - the latest P directive specifying
+the exchange rate from A to B, dated on or before the valuation date.
+.IP "2." 3
+a \f[I]transaction-implied market price\f[R] - a market price matching
+the transaction price used in the latest transaction where A is
+converted to B, dated on or before the valuation date.
+(\f[I]since hledger 1.18; experimental\f[R])
+.IP "3." 3
+a \f[I]reverse declared market price\f[R] - calculated by inverting a
+declared market price from B to A.
+.IP "4." 3
+a \f[I]reverse transaction-implied market price\f[R] - calculated by
+inverting a transaction-implied market price from B to A.
+.IP "5." 3
+an \f[I]indirect market price\f[R] - calculated by combining the
+shortest chain of market prices (any of the above types) leading from A
+to B.
 .SS --value: Flexible valuation
 .PP
 \f[I](experimental, added 201905)\f[R]
@@ -2243,9 +2282,6 @@
 \f[I]report interval\f[R]
 a flag (-D/-W/-M/-Q/-Y) or period expression that activates the
 report\[aq]s multi-period mode (whether showing one or many subperiods).
-.SS Combining -B, -V, -X, --value
-.PP
-The rightmost of these flags wins.
 .SH COMMANDS
 .PP
 hledger provides a number of subcommands; \f[C]hledger\f[R] with no
@@ -2838,13 +2874,15 @@
 \f[R]
 .fi
 .PP
-Note this is different from a normal balance report in several ways:
+This is different from a normal balance report in several ways:
 .IP \[bu] 2
 Only accounts with budget goals during the report period are shown, by
 default.
 .IP \[bu] 2
-In each column, in square brackets after the actual amount, budgeted
-amounts are shown, along with the percentage of budget used.
+In each column, in square brackets after the actual amount, budget goal
+amounts are shown, and the actual/goal percentage.
+(Note: budget goals should be in the same commodity as the actual
+amount.)
 .IP \[bu] 2
 All parent accounts are always shown, even in flat mode.
 Eg assets, assets:bank, and expenses above.
@@ -4171,7 +4209,7 @@
 .PP
 For help on these, see https://github.com/feuerbach/tasty#options
 (\f[C]-- --help\f[R] currently doesn\[aq]t show them).
-.SS Add-on Commands
+.SS Add-on commands
 .PP
 hledger also searches for external add-on commands, and will include
 these in the commands list.
@@ -4310,45 +4348,42 @@
 You may need to use \f[C]export\f[R].
 Here\[aq]s an explanation.
 .PP
-\f[B]\[dq]Illegal byte sequence\[dq] or \[dq]Invalid or incomplete
-multibyte or wide character\[dq] errors\f[R]
+\f[B]Getting errors like \[dq]Illegal byte sequence\[dq] or \[dq]Invalid
+or incomplete multibyte or wide character\[dq] or
+\[dq]commitAndReleaseBuffer: invalid argument (invalid
+character)\[dq]\f[R]
 .PD 0
 .P
 .PD
-In order to handle non-ascii letters and symbols (like \[Po]), hledger
-needs an appropriate locale.
-This is usually configured system-wide; you can also configure it
-temporarily.
-The locale may need to be one that supports UTF-8, if you built hledger
-with GHC < 7.2 (or possibly always, I\[aq]m not sure yet).
+Programs compiled with GHC (hledger, haskell build tools, etc.) need to
+have a UTF-8-aware locale configured in the environment, otherwise they
+will fail with these kinds of errors when they encounter non-ascii
+characters.
 .PP
-Here\[aq]s an example of setting the locale temporarily, on ubuntu
-gnu/linux:
+To fix it, set the LANG environment variable to some locale which
+supports UTF-8.
+The locale you choose must be installed on your system.
+.PP
+Here\[aq]s an example of setting LANG temporarily, on Ubuntu GNU/Linux:
 .IP
 .nf
 \f[C]
 $ file my.journal
-my.journal: UTF-8 Unicode text                 # <- the file is UTF8-encoded
-$ locale -a
+my.journal: UTF-8 Unicode text         # the file is UTF8-encoded
+$ echo $LANG
+C                                      # LANG is set to the default locale, which does not support UTF8
+$ locale -a                            # which locales are installed ?
 C
-en_US.utf8                             # <- a UTF8-aware locale is available
+en_US.utf8                             # here\[aq]s a UTF8-aware one we can use
 POSIX
-$ LANG=en_US.utf8 hledger -f my.journal print   # <- use it for this command
-\f[R]
-.fi
-.PP
-Here\[aq]s one way to set it permanently, there are probably better
-ways:
-.IP
-.nf
-\f[C]
-$ echo \[dq]export LANG=en_US.UTF-8\[dq] >>\[ti]/.bash_profile
-$ bash --login
+$ LANG=en_US.utf8 hledger -f my.journal print   # ensure it is used for this command
 \f[R]
 .fi
 .PP
-If we preferred to use eg \f[C]fr_FR.utf8\f[R], we might have to install
-that first:
+If available, \f[C]C.UTF-8\f[R] will also work.
+If your preferred locale isn\[aq]t listed by \f[C]locale -a\f[R], you
+might need to install it.
+Eg on Ubuntu/Debian:
 .IP
 .nf
 \f[C]
@@ -4366,9 +4401,27 @@
 \f[R]
 .fi
 .PP
-Note some platforms allow variant locale spellings, but not all (ubuntu
-accepts \f[C]fr_FR.UTF8\f[R], mac osx requires exactly
-\f[C]fr_FR.UTF-8\f[R]).
+Here\[aq]s how you could set it permanently, if you use a bash shell:
+.IP
+.nf
+\f[C]
+$ echo \[dq]export LANG=en_US.utf8\[dq] >>\[ti]/.bash_profile
+$ bash --login
+\f[R]
+.fi
+.PP
+Exact spelling and capitalisation may be important.
+Note the difference on MacOS (\f[C]UTF-8\f[R], not \f[C]utf8\f[R]).
+Some platforms (eg ubuntu) allow variant spellings, but others (eg
+macos) require it to be exact:
+.IP
+.nf
+\f[C]
+$ locale -a | grep -iE en_us.*utf
+en_US.UTF-8
+$ LANG=en_US.UTF-8 hledger -f my.journal print
+\f[R]
+.fi
 
 
 .SH "REPORTING BUGS"
diff --git a/embeddedfiles/hledger.info b/embeddedfiles/hledger.info
--- a/embeddedfiles/hledger.info
+++ b/embeddedfiles/hledger.info
@@ -3,8 +3,8 @@
 
 File: hledger.info,  Node: Top,  Next: COMMON TASKS,  Up: (dir)
 
-hledger(1) hledger 1.17.1.1
-***************************
+hledger(1) hledger 1.18
+***********************
 
 hledger - a command-line accounting tool
 
@@ -1021,14 +1021,6 @@
      JSON, read the Haskell type definitions, which are mostly in
      https://github.com/simonmichael/hledger/blob/master/hledger-lib/Hledger/Data/Types.hs.
 
-   * The JSON output from hledger commands is essentially the same as
-     the JSON served by hledger-web's JSON API, but pretty printed,
-     using line breaks and indentation.  Our pretty printer has the
-     ability to elide data in certain cases - rendering non-strings as
-     if they were strings, or displaying "FOO.." instead of FOO's full
-     details.  This should never happen in hledger's JSON output; if you
-     see otherwise, please report as a bug.
-
    * hledger represents quantities as Decimal values storing up to 255
      significant digits, eg for repeating decimals.  Such numbers can
      arise in practice (from automatically-calculated transaction
@@ -1052,17 +1044,22 @@
    * account alias directives and options: 'alias /REGEX/ =
      REPLACEMENT', '--alias /REGEX/=REPLACEMENT'
 
-   hledger's regular expressions come from the regex-tdfa library.  In
-general they:
+   hledger's regular expressions come from the regex-tdfa library.  If
+they're not doing what you expect, it's important to know exactly what
+they support:
 
-   * are case insensitive
-   * are infix matching (do not need to match the entire thing being
-     matched)
-   * are POSIX extended regular expressions
-   * also support GNU word boundaries (\<, \>, \b, \B)
-   * and parenthesised capturing groups and numeric backreferences in
-     replacement strings
-   * do not support mode modifiers like (?s)
+  1. they are case insensitive
+  2. they are infix matching (they do not need to match the entire thing
+     being matched)
+  3. they are POSIX ERE (extended regular expressions)
+  4. they also support GNU word boundaries ('\b', '\B', '\<', '\>')
+  5. they do not support backreferences; if you write '\1', it will
+     match the digit '1'.  Except when doing text replacement, eg in
+     account aliases, where backreferences can be used in the
+     replacement string to reference capturing groups in the search
+     regexp.
+  6. they do not support mode modifiers ('(?s)'), character classes
+     ('\w', '\d'), or anything else not mentioned above.
 
    Some things to note:
 
@@ -1146,17 +1143,18 @@
 
    Examples:
 
-'-b          begin on St. Patrick's day 2016
+'-b           begin on St. Patrick's day 2016
 2016/3/17'
-'-e 12/1'    end at the start of december 1st of the current year
-             (11/30 will be the last date included)
-'-b          all transactions on or after the 1st of the current month
+'-e 12/1'     end at the start of december 1st of the current year
+              (11/30 will be the last date included)
+'-b           all transactions on or after the 1st of the current month
 thismonth'
-'-p          all transactions in the current month
+'-p           all transactions in the current month
 thismonth'
-'date:2016/3/17-'the above written as queries instead
-'date:-12/1'
-'date:thismonth-'
+'date:2016/3/17..'the above written as queries instead ('..' can also be
+              replaced with '-')
+'date:..12/1'
+'date:thismonth..'
 'date:thismonth'
 
 
@@ -1189,11 +1187,11 @@
 
    Keywords like "from" and "to" are optional, and so are the spaces, as
 long as you don't run two dates together.  "to" can also be written as
-"-".  These are equivalent to the above:
+".."  or "-".  These are equivalent to the above:
 
 '-p "2009/1/1 2009/4/1"'
 '-p2009/1/1to2009/4/1'
-'-p2009/1/1-2009/4/1'
+'-p2009/1/1..2009/4/1'
 
    Dates are smart dates, so if the current year is 2009, the above can
 also be written as:
@@ -1300,7 +1298,7 @@
 balance and register will show only the uppermost accounts in the
 account tree, down to level N. Use this when you want a summary with
 less detail.  This flag has the same effect as a 'depth:' query argument
-(so '-2', '--depth=2' or 'depth:2' are basically equivalent).
+(so '-2', '--depth=2' or 'depth:2' are equivalent).
 
 
 File: hledger.info,  Node: Pivoting,  Next: Valuation,  Prev: Depth limiting,  Up: OPTIONS
@@ -1365,47 +1363,61 @@
 2.17 Valuation
 ==============
 
+hledger can show cost reports, where amounts are converted to their cost
+or sale amount at transaction time; or value reports, where amounts are
+converted to their market value in another currency/commodity at a
+specified date (using market prices inferred from your transactions, or
+declared with P directives).
+
+   We call this "valuation", and it is controlled by the
+'--value=VALUATIONTYPE[,COMMODITY]' option.  It can get a little
+involved, so we cover all the details below.  But most of the time, all
+you need to do is use these simpler flags instead:
+
+   * '-B' to convert to cost/sale amount, or
+   * '-V' to convert to market value in your base currency.  Or
+     occasionally,
+   * '-X COMMODITY' to convert to market value in some other currency.
+
 * Menu:
 
 * -B Cost::
-* -V Market value::
+* -V Value::
 * -X Market value in specified commodity::
+* Market prices::
 * --value Flexible valuation::
 * Effect of --value on reports::
-* Combining -B -V -X --value::
 
 
-File: hledger.info,  Node: -B Cost,  Next: -V Market value,  Up: Valuation
+File: hledger.info,  Node: -B Cost,  Next: -V Value,  Up: Valuation
 
 2.17.1 -B: Cost
 ---------------
 
-The '-B/--cost' flag converts amounts to their cost (or selling price)
-at transaction time, if they have a transaction price specified.  This
-flag is equivalent to '--value=cost', described below.
+The '-B/--cost' flag converts amounts to their cost or sale amount at
+transaction time, if they have a transaction price specified.  (It is
+equivalent to '--value=cost'.)
 
 
-File: hledger.info,  Node: -V Market value,  Next: -X Market value in specified commodity,  Prev: -B Cost,  Up: Valuation
+File: hledger.info,  Node: -V Value,  Next: -X Market value in specified commodity,  Prev: -B Cost,  Up: Valuation
 
-2.17.2 -V: Market value
------------------------
+2.17.2 -V: Value
+----------------
 
-The '-V/--market' flag converts reported amounts to their market value
-in a default valuation commodity, using the market prices in effect on a
-default valuation date.  For single period reports, the valuation date
-is today (equivalent to '--value=now'); for multiperiod reports, it is
-the last day of each subperiod (equivalent to '--value=end').
+The '-V/--market' flag converts reported amounts to market value in
+their _default valuation commodity_, using the market prices in effect
+on a _default valuation date_.  (More on these below.)
 
    The default valuation commodity is the one referenced in the latest
-applicable market price dated on or before the valuation date.  If most
-of your P declarations lead to a single home currency, this will usually
-be what you want.  (To specify the commodity, see -X below.)
+applicable market price dated on or before the valuation date.
+Typically your P declarations or currency exchange transactions
+reference a single base currency, and -V will pick that.
 
-   Note that in hledger, market prices are always declared explicitly
-with P directives; we do not infer them from transaction prices as
-Ledger does.
+   The default valuation date is today for single period reports
+(equivalent to '--value=now'), or the last day of each subperiod for
+multiperiod reports (equivalent to '--value=end').
 
-   Here's a quick example of -V:
+   An example:
 
 ; one euro is worth this many dollars from nov 1
 P 2016/11/01 € $1.10
@@ -1435,19 +1447,47 @@
              $103.00  assets:euros
 
 
-File: hledger.info,  Node: -X Market value in specified commodity,  Next: --value Flexible valuation,  Prev: -V Market value,  Up: Valuation
+File: hledger.info,  Node: -X Market value in specified commodity,  Next: Market prices,  Prev: -V Value,  Up: Valuation
 
 2.17.3 -X: Market value in specified commodity
 ----------------------------------------------
 
 The '-X/--exchange' option is like '-V', except it specifies the target
-commodity you would like to convert to.  It is equivalent to
-'--value=now,COMM' or '--value=end,COMM'.
+commodity you would like to convert to.  (It is equivalent to
+'--value=now,COMM' or '--value=end,COMM'.)
 
 
-File: hledger.info,  Node: --value Flexible valuation,  Next: Effect of --value on reports,  Prev: -X Market value in specified commodity,  Up: Valuation
+File: hledger.info,  Node: Market prices,  Next: --value Flexible valuation,  Prev: -X Market value in specified commodity,  Up: Valuation
 
-2.17.4 -value: Flexible valuation
+2.17.4 Market prices
+--------------------
+
+To convert a commodity A to commodity B, hledger looks for a suitable
+market price (exchange rate) in the following ways, in this order of
+preference:
+
+  1. a _declared market price_ - the latest P directive specifying the
+     exchange rate from A to B, dated on or before the valuation date.
+
+  2. a _transaction-implied market price_ - a market price matching the
+     transaction price used in the latest transaction where A is
+     converted to B, dated on or before the valuation date.  (_since
+     hledger 1.18; experimental_)
+
+  3. a _reverse declared market price_ - calculated by inverting a
+     declared market price from B to A.
+
+  4. a _reverse transaction-implied market price_ - calculated by
+     inverting a transaction-implied market price from B to A.
+
+  5. an _indirect market price_ - calculated by combining the shortest
+     chain of market prices (any of the above types) leading from A to
+     B.
+
+
+File: hledger.info,  Node: --value Flexible valuation,  Next: Effect of --value on reports,  Prev: Market prices,  Up: Valuation
+
+2.17.5 -value: Flexible valuation
 ---------------------------------
 
 _(experimental, added 201905)_
@@ -1617,9 +1657,9 @@
     b          -0.50A
 
 
-File: hledger.info,  Node: Effect of --value on reports,  Next: Combining -B -V -X --value,  Prev: --value Flexible valuation,  Up: Valuation
+File: hledger.info,  Node: Effect of --value on reports,  Prev: --value Flexible valuation,  Up: Valuation
 
-2.17.5 Effect of -value on reports
+2.17.6 Effect of -value on reports
 ----------------------------------
 
 Here is a reference for how '--value' currently affects each part of
@@ -1733,14 +1773,6 @@
      subperiods).
 
 
-File: hledger.info,  Node: Combining -B -V -X --value,  Prev: Effect of --value on reports,  Up: Valuation
-
-2.17.6 Combining -B, -V, -X, -value
------------------------------------
-
-The rightmost of these flags wins.
-
-
 File: hledger.info,  Node: COMMANDS,  Next: ENVIRONMENT,  Prev: OPTIONS,  Up: Top
 
 3 COMMANDS
@@ -1793,7 +1825,7 @@
 * stats::
 * tags::
 * test::
-* Add-on Commands::
+* Add-on commands::
 
 
 File: hledger.info,  Node: accounts,  Next: activity,  Up: COMMANDS
@@ -2319,14 +2351,14 @@
 ----------------------++----------------------------------------------------
                       ||      0 [              0]       0 [              0] 
 
-   Note this is different from a normal balance report in several ways:
+   This is different from a normal balance report in several ways:
 
    * Only accounts with budget goals during the report period are shown,
      by default.
 
-   * In each column, in square brackets after the actual amount,
-     budgeted amounts are shown, along with the percentage of budget
-     used.
+   * In each column, in square brackets after the actual amount, budget
+     goal amounts are shown, and the actual/goal percentage.  (Note:
+     budget goals should be in the same commodity as the actual amount.)
 
    * All parent accounts are always shown, even in flat mode.  Eg
      assets, assets:bank, and expenses above.
@@ -3494,7 +3526,7 @@
 instead.
 
 
-File: hledger.info,  Node: test,  Next: Add-on Commands,  Prev: tags,  Up: COMMANDS
+File: hledger.info,  Node: test,  Next: Add-on commands,  Prev: tags,  Up: COMMANDS
 
 3.29 test
 =========
@@ -3521,9 +3553,9 @@
 ('-- --help' currently doesn't show them).
 
 
-File: hledger.info,  Node: Add-on Commands,  Prev: test,  Up: COMMANDS
+File: hledger.info,  Node: Add-on commands,  Prev: test,  Up: COMMANDS
 
-3.30 Add-on Commands
+3.30 Add-on commands
 ====================
 
 hledger also searches for external add-on commands, and will include
@@ -3562,7 +3594,7 @@
 * interest::
 
 
-File: hledger.info,  Node: ui,  Next: web,  Up: Add-on Commands
+File: hledger.info,  Node: ui,  Next: web,  Up: Add-on commands
 
 3.30.1 ui
 ---------
@@ -3570,7 +3602,7 @@
 hledger-ui provides an efficient terminal interface.
 
 
-File: hledger.info,  Node: web,  Next: iadd,  Prev: ui,  Up: Add-on Commands
+File: hledger.info,  Node: web,  Next: iadd,  Prev: ui,  Up: Add-on commands
 
 3.30.2 web
 ----------
@@ -3580,7 +3612,7 @@
    Third party add-ons, maintained separately from hledger, include:
 
 
-File: hledger.info,  Node: iadd,  Next: interest,  Prev: web,  Up: Add-on Commands
+File: hledger.info,  Node: iadd,  Next: interest,  Prev: web,  Up: Add-on commands
 
 3.30.3 iadd
 -----------
@@ -3589,7 +3621,7 @@
 command.
 
 
-File: hledger.info,  Node: interest,  Prev: iadd,  Up: Add-on Commands
+File: hledger.info,  Node: interest,  Prev: iadd,  Up: Add-on commands
 
 3.30.4 interest
 ---------------
@@ -3689,32 +3721,32 @@
 variable.  The command 'env | grep LEDGER_FILE' should show it.  You may
 need to use 'export'.  Here's an explanation.
 
-   *"Illegal byte sequence" or "Invalid or incomplete multibyte or wide
-character" errors*
-In order to handle non-ascii letters and symbols (like £), hledger needs
-an appropriate locale.  This is usually configured system-wide; you can
-also configure it temporarily.  The locale may need to be one that
-supports UTF-8, if you built hledger with GHC < 7.2 (or possibly always,
-I'm not sure yet).
+   *Getting errors like "Illegal byte sequence" or "Invalid or
+incomplete multibyte or wide character" or "commitAndReleaseBuffer:
+invalid argument (invalid character)"*
+Programs compiled with GHC (hledger, haskell build tools, etc.)  need to
+have a UTF-8-aware locale configured in the environment, otherwise they
+will fail with these kinds of errors when they encounter non-ascii
+characters.
 
-   Here's an example of setting the locale temporarily, on ubuntu
-gnu/linux:
+   To fix it, set the LANG environment variable to some locale which
+supports UTF-8.  The locale you choose must be installed on your system.
 
+   Here's an example of setting LANG temporarily, on Ubuntu GNU/Linux:
+
 $ file my.journal
-my.journal: UTF-8 Unicode text                 # <- the file is UTF8-encoded
-$ locale -a
+my.journal: UTF-8 Unicode text         # the file is UTF8-encoded
+$ echo $LANG
+C                                      # LANG is set to the default locale, which does not support UTF8
+$ locale -a                            # which locales are installed ?
 C
-en_US.utf8                             # <- a UTF8-aware locale is available
+en_US.utf8                             # here's a UTF8-aware one we can use
 POSIX
-$ LANG=en_US.utf8 hledger -f my.journal print   # <- use it for this command
-
-   Here's one way to set it permanently, there are probably better ways:
-
-$ echo "export LANG=en_US.UTF-8" >>~/.bash_profile
-$ bash --login
+$ LANG=en_US.utf8 hledger -f my.journal print   # ensure it is used for this command
 
-   If we preferred to use eg 'fr_FR.utf8', we might have to install that
-first:
+   If available, 'C.UTF-8' will also work.  If your preferred locale
+isn't listed by 'locale -a', you might need to install it.  Eg on
+Ubuntu/Debian:
 
 $ apt-get install language-pack-fr
 $ locale -a
@@ -3728,193 +3760,203 @@
 POSIX
 $ LANG=fr_FR.utf8 hledger -f my.journal print
 
-   Note some platforms allow variant locale spellings, but not all
-(ubuntu accepts 'fr_FR.UTF8', mac osx requires exactly 'fr_FR.UTF-8').
+   Here's how you could set it permanently, if you use a bash shell:
 
+$ echo "export LANG=en_US.utf8" >>~/.bash_profile
+$ bash --login
+
+   Exact spelling and capitalisation may be important.  Note the
+difference on MacOS ('UTF-8', not 'utf8').  Some platforms (eg ubuntu)
+allow variant spellings, but others (eg macos) require it to be exact:
+
+$ locale -a | grep -iE en_us.*utf
+en_US.UTF-8
+$ LANG=en_US.UTF-8 hledger -f my.journal print
+
 
 Tag Table:
 Node: Top68
-Node: COMMON TASKS2323
-Ref: #common-tasks2435
-Node: Getting help2842
-Ref: #getting-help2974
-Node: Constructing command lines3527
-Ref: #constructing-command-lines3719
-Node: Starting a journal file4416
-Ref: #starting-a-journal-file4614
-Node: Setting opening balances5802
-Ref: #setting-opening-balances5998
-Node: Recording transactions9139
-Ref: #recording-transactions9319
-Node: Reconciling9875
-Ref: #reconciling10018
-Node: Reporting12275
-Ref: #reporting12415
-Node: Migrating to a new file16414
-Ref: #migrating-to-a-new-file16562
-Node: OPTIONS16861
-Ref: #options16968
-Node: General options17338
-Ref: #general-options17463
-Node: Command options20233
-Ref: #command-options20384
-Node: Command arguments20782
-Ref: #command-arguments20929
-Node: Queries21809
-Ref: #queries21964
-Node: Special characters in arguments and queries25926
-Ref: #special-characters-in-arguments-and-queries26154
-Node: More escaping26605
-Ref: #more-escaping26767
-Node: Even more escaping27063
-Ref: #even-more-escaping27257
-Node: Less escaping27928
-Ref: #less-escaping28090
-Node: Unicode characters28335
-Ref: #unicode-characters28517
-Node: Input files29929
-Ref: #input-files30072
-Node: Output destination32001
-Ref: #output-destination32153
-Node: Output format32578
-Ref: #output-format32728
-Node: Regular expressions34776
-Ref: #regular-expressions34933
-Node: Smart dates36294
-Ref: #smart-dates36445
-Node: Report start & end date37806
-Ref: #report-start-end-date37978
-Node: Report intervals39416
-Ref: #report-intervals39581
-Node: Period expressions39971
-Ref: #period-expressions40131
-Node: Depth limiting44257
-Ref: #depth-limiting44401
-Node: Pivoting44743
-Ref: #pivoting44866
-Node: Valuation46542
-Ref: #valuation46644
-Node: -B Cost46824
-Ref: #b-cost46935
-Node: -V Market value47133
-Ref: #v-market-value47307
-Node: -X Market value in specified commodity48739
-Ref: #x-market-value-in-specified-commodity48978
-Node: --value Flexible valuation49154
-Ref: #value-flexible-valuation49380
-Node: Effect of --value on reports53885
-Ref: #effect-of---value-on-reports54101
-Node: Combining -B -V -X --value59647
-Ref: #combining--b--v--x---value59830
-Node: COMMANDS59866
-Ref: #commands59974
-Node: accounts61058
-Ref: #accounts61156
-Node: activity61855
-Ref: #activity61965
-Node: add62348
-Ref: #add62447
-Node: balance65186
-Ref: #balance65297
-Node: Classic balance report66755
-Ref: #classic-balance-report66928
-Node: Customising the classic balance report68297
-Ref: #customising-the-classic-balance-report68525
-Node: Colour support70601
-Ref: #colour-support70768
-Node: Flat mode70941
-Ref: #flat-mode71089
-Node: Depth limited balance reports71502
-Ref: #depth-limited-balance-reports71687
-Node: Percentages72143
-Ref: #percentages72309
-Node: Multicolumn balance report73446
-Ref: #multicolumn-balance-report73626
-Node: Budget report78888
-Ref: #budget-report79031
-Node: Nested budgets84233
-Ref: #nested-budgets84345
-Ref: #output-format-187826
-Node: balancesheet88023
-Ref: #balancesheet88159
-Node: balancesheetequity89625
-Ref: #balancesheetequity89774
-Node: cashflow90497
-Ref: #cashflow90625
-Node: check-dates91804
-Ref: #check-dates91931
-Node: check-dupes92210
-Ref: #check-dupes92334
-Node: close92627
-Ref: #close92741
-Node: close usage94263
-Ref: #close-usage94356
-Node: commodities97169
-Ref: #commodities97296
-Node: descriptions97378
-Ref: #descriptions97506
-Node: diff97687
-Ref: #diff97793
-Node: files98840
-Ref: #files98940
-Node: help99087
-Ref: #help99187
-Node: import100268
-Ref: #import100382
-Node: Importing balance assignments101275
-Ref: #importing-balance-assignments101423
-Node: incomestatement102072
-Ref: #incomestatement102205
-Node: notes103692
-Ref: #notes103805
-Node: payees103931
-Ref: #payees104037
-Node: prices104195
-Ref: #prices104301
-Node: print104642
-Ref: #print104752
-Node: print-unique109538
-Ref: #print-unique109664
-Node: register109949
-Ref: #register110076
-Node: Custom register output114248
-Ref: #custom-register-output114377
-Node: register-match115714
-Ref: #register-match115848
-Node: rewrite116199
-Ref: #rewrite116314
-Node: Re-write rules in a file118169
-Ref: #re-write-rules-in-a-file118303
-Node: Diff output format119513
-Ref: #diff-output-format119682
-Node: rewrite vs print --auto120774
-Ref: #rewrite-vs.-print---auto120953
-Node: roi121509
-Ref: #roi121607
-Node: stats122619
-Ref: #stats122718
-Node: tags123506
-Ref: #tags123604
-Node: test123898
-Ref: #test124006
-Node: Add-on Commands124753
-Ref: #add-on-commands124870
-Node: ui126213
-Ref: #ui126301
-Node: web126355
-Ref: #web126458
-Node: iadd126574
-Ref: #iadd126685
-Node: interest126767
-Ref: #interest126874
-Node: ENVIRONMENT127114
-Ref: #environment127226
-Node: FILES128055
-Ref: #files-1128158
-Node: LIMITATIONS128371
-Ref: #limitations128490
-Node: TROUBLESHOOTING129232
-Ref: #troubleshooting129345
+Node: COMMON TASKS2315
+Ref: #common-tasks2427
+Node: Getting help2834
+Ref: #getting-help2966
+Node: Constructing command lines3519
+Ref: #constructing-command-lines3711
+Node: Starting a journal file4408
+Ref: #starting-a-journal-file4606
+Node: Setting opening balances5794
+Ref: #setting-opening-balances5990
+Node: Recording transactions9131
+Ref: #recording-transactions9311
+Node: Reconciling9867
+Ref: #reconciling10010
+Node: Reporting12267
+Ref: #reporting12407
+Node: Migrating to a new file16406
+Ref: #migrating-to-a-new-file16554
+Node: OPTIONS16853
+Ref: #options16960
+Node: General options17330
+Ref: #general-options17455
+Node: Command options20225
+Ref: #command-options20376
+Node: Command arguments20774
+Ref: #command-arguments20921
+Node: Queries21801
+Ref: #queries21956
+Node: Special characters in arguments and queries25918
+Ref: #special-characters-in-arguments-and-queries26146
+Node: More escaping26597
+Ref: #more-escaping26759
+Node: Even more escaping27055
+Ref: #even-more-escaping27249
+Node: Less escaping27920
+Ref: #less-escaping28082
+Node: Unicode characters28327
+Ref: #unicode-characters28509
+Node: Input files29921
+Ref: #input-files30064
+Node: Output destination31993
+Ref: #output-destination32145
+Node: Output format32570
+Ref: #output-format32720
+Node: Regular expressions34302
+Ref: #regular-expressions34459
+Node: Smart dates36195
+Ref: #smart-dates36346
+Node: Report start & end date37707
+Ref: #report-start-end-date37879
+Node: Report intervals39376
+Ref: #report-intervals39541
+Node: Period expressions39931
+Ref: #period-expressions40091
+Node: Depth limiting44227
+Ref: #depth-limiting44371
+Node: Pivoting44703
+Ref: #pivoting44826
+Node: Valuation46502
+Ref: #valuation46604
+Node: -B Cost47524
+Ref: #b-cost47628
+Node: -V Value47800
+Ref: #v-value47953
+Node: -X Market value in specified commodity49226
+Ref: #x-market-value-in-specified-commodity49445
+Node: Market prices49623
+Ref: #market-prices49808
+Node: --value Flexible valuation50733
+Ref: #value-flexible-valuation50934
+Node: Effect of --value on reports55439
+Ref: #effect-of---value-on-reports55620
+Node: COMMANDS61166
+Ref: #commands61274
+Node: accounts62358
+Ref: #accounts62456
+Node: activity63155
+Ref: #activity63265
+Node: add63648
+Ref: #add63747
+Node: balance66486
+Ref: #balance66597
+Node: Classic balance report68055
+Ref: #classic-balance-report68228
+Node: Customising the classic balance report69597
+Ref: #customising-the-classic-balance-report69825
+Node: Colour support71901
+Ref: #colour-support72068
+Node: Flat mode72241
+Ref: #flat-mode72389
+Node: Depth limited balance reports72802
+Ref: #depth-limited-balance-reports72987
+Node: Percentages73443
+Ref: #percentages73609
+Node: Multicolumn balance report74746
+Ref: #multicolumn-balance-report74926
+Node: Budget report80188
+Ref: #budget-report80331
+Node: Nested budgets85597
+Ref: #nested-budgets85709
+Ref: #output-format-189190
+Node: balancesheet89387
+Ref: #balancesheet89523
+Node: balancesheetequity90989
+Ref: #balancesheetequity91138
+Node: cashflow91861
+Ref: #cashflow91989
+Node: check-dates93168
+Ref: #check-dates93295
+Node: check-dupes93574
+Ref: #check-dupes93698
+Node: close93991
+Ref: #close94105
+Node: close usage95627
+Ref: #close-usage95720
+Node: commodities98533
+Ref: #commodities98660
+Node: descriptions98742
+Ref: #descriptions98870
+Node: diff99051
+Ref: #diff99157
+Node: files100204
+Ref: #files100304
+Node: help100451
+Ref: #help100551
+Node: import101632
+Ref: #import101746
+Node: Importing balance assignments102639
+Ref: #importing-balance-assignments102787
+Node: incomestatement103436
+Ref: #incomestatement103569
+Node: notes105056
+Ref: #notes105169
+Node: payees105295
+Ref: #payees105401
+Node: prices105559
+Ref: #prices105665
+Node: print106006
+Ref: #print106116
+Node: print-unique110902
+Ref: #print-unique111028
+Node: register111313
+Ref: #register111440
+Node: Custom register output115612
+Ref: #custom-register-output115741
+Node: register-match117078
+Ref: #register-match117212
+Node: rewrite117563
+Ref: #rewrite117678
+Node: Re-write rules in a file119533
+Ref: #re-write-rules-in-a-file119667
+Node: Diff output format120877
+Ref: #diff-output-format121046
+Node: rewrite vs print --auto122138
+Ref: #rewrite-vs.-print---auto122317
+Node: roi122873
+Ref: #roi122971
+Node: stats123983
+Ref: #stats124082
+Node: tags124870
+Ref: #tags124968
+Node: test125262
+Ref: #test125370
+Node: Add-on commands126117
+Ref: #add-on-commands126234
+Node: ui127577
+Ref: #ui127665
+Node: web127719
+Ref: #web127822
+Node: iadd127938
+Ref: #iadd128049
+Node: interest128131
+Ref: #interest128238
+Node: ENVIRONMENT128478
+Ref: #environment128590
+Node: FILES129419
+Ref: #files-1129522
+Node: LIMITATIONS129735
+Ref: #limitations129854
+Node: TROUBLESHOOTING130596
+Ref: #troubleshooting130709
 
 End Tag Table
 
diff --git a/embeddedfiles/hledger.txt b/embeddedfiles/hledger.txt
--- a/embeddedfiles/hledger.txt
+++ b/embeddedfiles/hledger.txt
@@ -868,14 +868,6 @@
          https://github.com/simonmichael/hledger/blob/master/hledger-
          lib/Hledger/Data/Types.hs.
 
-       o The JSON output from hledger commands is essentially the same as  the
-         JSON served by hledger-web's JSON API, but pretty printed, using line
-         breaks and indentation.  Our pretty printer has the ability to  elide
-         data  in  certain  cases  -  rendering  non-strings  as  if they were
-         strings, or displaying "FOO.." instead of FOO's full  details.   This
-         should  never  happen in hledger's JSON output; if you see otherwise,
-         please report as a bug.
-
        o hledger represents quantities as Decimal values  storing  up  to  255
          significant  digits,  eg  for  repeating  decimals.  Such numbers can
          arise in practice (from automatically-calculated transaction prices),
@@ -896,22 +888,26 @@
        o account alias directives and options: alias  /REGEX/  =  REPLACEMENT,
          --alias /REGEX/=REPLACEMENT
 
-       hledger's  regular  expressions  come  from the regex-tdfa library.  In
-       general they:
+       hledger's  regular  expressions  come  from the regex-tdfa library.  If
+       they're not doing what you expect, it's important to know exactly  what
+       they support:
 
-       o are case insensitive
+       1. they are case insensitive
 
-       o are infix matching (do not need  to  match  the  entire  thing  being
-         matched)
+       2. they  are infix matching (they do not need to match the entire thing
+          being matched)
 
-       o are POSIX extended regular expressions
+       3. they are POSIX ERE (extended regular expressions)
 
-       o also support GNU word boundaries (\<, \>, \b, \B)
+       4. they also support GNU word boundaries (\b, \B, \<, \>)
 
-       o and  parenthesised capturing groups and numeric backreferences in re-
-         placement strings
+       5. they do not support backreferences; if you write \1, it  will  match
+          the  digit  1.   Except  when  doing text replacement, eg in account
+          aliases, where backreferences can be used in the replacement  string
+          to reference capturing groups in the search regexp.
 
-       o do not support mode modifiers like (?s)
+       6. they  do  not  support mode modifiers ((?s)), character classes (\w,
+          \d), or anything else not mentioned above.
 
        Some things to note:
 
@@ -938,6 +934,7 @@
        2004/10/1,   2004-01-01,   exact date, several separators allowed.   Year
        2004.9.1                   is 4+ digits, month is 1-12, day is 1-31
        2004                       start of year
+
        2004/10                    start of month
        10/1                       month and day in current year
        21                         day in current month
@@ -986,43 +983,44 @@
 
        Examples:
 
-       -b 2016/3/17      begin on St. Patrick's day 2016
-       -e 12/1           end at the start of  december  1st  of  the  current  year
-                         (11/30 will be the last date included)
-       -b thismonth      all transactions on or after the 1st of the current month
-       -p thismonth      all transactions in the current month
-       date:2016/3/17-   the above written as queries instead
-       date:-12/1
-       date:thismonth-
+       -b 2016/3/17       begin on St. Patrick's day 2016
+       -e 12/1            end at the start of  december  1st  of  the  current  year
+                          (11/30 will be the last date included)
+       -b thismonth       all transactions on or after the 1st of the current month
+       -p thismonth       all transactions in the current month
+       date:2016/3/17..   the above written as queries instead (.. can also  be  re-
+                          placed with -)
+       date:..12/1
+       date:thismonth..
        date:thismonth
 
    Report intervals
        A report interval can be specified so that commands like register, bal-
-       ance  and  activity will divide their reports into multiple subperiods.
-       The  basic  intervals  can  be  selected  with   one   of   -D/--daily,
-       -W/--weekly,  -M/--monthly,  -Q/--quarterly, or -Y/--yearly.  More com-
-       plex intervals may be specified with a period expression.   Report  in-
+       ance and activity will divide their reports into  multiple  subperiods.
+       The   basic   intervals   can  be  selected  with  one  of  -D/--daily,
+       -W/--weekly, -M/--monthly, -Q/--quarterly, or -Y/--yearly.   More  com-
+       plex  intervals  may be specified with a period expression.  Report in-
        tervals can not be specified with a query.
 
    Period expressions
-       The  -p/--period  option accepts period expressions, a shorthand way of
+       The -p/--period option accepts period expressions, a shorthand  way  of
        expressing a start date, end date, and/or report interval all at once.
 
-       Here's a basic period expression specifying the first quarter of  2009.
-       Note,  hledger  always treats start dates as inclusive and end dates as
+       Here's  a basic period expression specifying the first quarter of 2009.
+       Note, hledger always treats start dates as inclusive and end  dates  as
        exclusive:
 
        -p "from 2009/1/1 to 2009/4/1"
 
-       Keywords like "from" and "to" are optional, and so are the  spaces,  as
-       long  as you don't run two dates together.  "to" can also be written as
-       "-".  These are equivalent to the above:
+       Keywords  like  "from" and "to" are optional, and so are the spaces, as
+       long as you don't run two dates together.  "to" can also be written  as
+       ".." or "-".  These are equivalent to the above:
 
        -p "2009/1/1 2009/4/1"
        -p2009/1/1to2009/4/1
-       -p2009/1/1-2009/4/1
+       -p2009/1/1..2009/4/1
 
-       Dates are smart dates, so if the current year is 2009,  the  above  can
+       Dates  are  smart  dates, so if the current year is 2009, the above can
        also be written as:
 
        -p "1/1 4/1"
@@ -1036,64 +1034,62 @@
                             1, 2009
        -p "from 2009/1"     the same
        -p "from 2009"       the same
-       -p "to 2009"         everything  before january
+       -p "to 2009"         everything before  january
                             1, 2009
 
-       A single date with no "from" or "to" defines both  the  start  and  end
+       A  single  date  with  no "from" or "to" defines both the start and end
        date like so:
 
-       -p "2009"       the  year 2009; equivalent
+       -p "2009"       the year 2009;  equivalent
                        to "2009/1/1 to 2010/1/1"
-       -p "2009/1"     the month of jan;  equiva-
+       -p "2009/1"     the  month of jan; equiva-
                        lent   to   "2009/1/1   to
                        2009/2/1"
-       -p "2009/1/1"   just that day;  equivalent
+       -p "2009/1/1"   just  that day; equivalent
                        to "2009/1/1 to 2009/1/2"
 
-       The  argument  of  -p can also begin with, or be, a report interval ex-
+       The argument of -p can also begin with, or be, a  report  interval  ex-
        pression.  The basic report intervals are daily, weekly, monthly, quar-
-       terly,  or yearly, which have the same effect as the -D,-W,-M,-Q, or -Y
-       flags.  Between report interval and start/end dates (if any), the  word
+       terly, or yearly, which have the same effect as the -D,-W,-M,-Q, or  -Y
+       flags.   Between report interval and start/end dates (if any), the word
        in is optional.  Examples:
 
        -p "weekly from 2009/1/1 to 2009/4/1"
        -p "monthly in 2008"
        -p "quarterly"
 
-       Note  that  weekly, monthly, quarterly and yearly intervals will always
+       Note that weekly, monthly, quarterly and yearly intervals  will  always
        start on the first day on week, month, quarter or year accordingly, and
-       will  end on the last day of same period, even if associated period ex-
+       will end on the last day of same period, even if associated period  ex-
        pression specifies different explicit start and end date.
 
        For example:
 
-       -p "weekly from  2009/1/1   starts on 2008/12/29, closest preceding Mon-
+       -p  "weekly from 2009/1/1   starts on 2008/12/29, closest preceding Mon-
        to 2009/4/1"                day
-
-
-       -p      "monthly       in   starts on 2018/11/01
+       -p       "monthly      in   starts on 2018/11/01
        2008/11/25"
-       -p     "quarterly    from   starts on 2009/04/01,  ends  on  2009/06/30,
+       -p    "quarterly     from   starts  on  2009/04/01,  ends on 2009/06/30,
        2009-05-05 to 2009-06-01"   which are first and last days of Q2 2009
        -p      "yearly      from   starts on 2009/01/01, first day of 2009
        2009-12-29"
 
-       The following more complex report intervals  are  also  supported:  bi-
+       The  following  more  complex  report intervals are also supported: bi-
        weekly,   bimonthly,   every   day|week|month|quarter|year,   every   N
        days|weeks|months|quarters|years.
 
-       All of these will start on the first day of the  requested  period  and
+       All  of  these  will start on the first day of the requested period and
        end on the last one, as described above.
 
        Examples:
 
-       -p "bimonthly from 2008"    periods  will have boundaries on 2008/01/01,
+       -p "bimonthly from 2008"    periods will have boundaries on  2008/01/01,
                                    2008/03/01, ...
        -p "every 2 weeks"          starts on closest preceding Monday
-       -p "every  5  month  from   periods  will have boundaries on 2009/03/01,
+       -p  "every  5  month from   periods will have boundaries on  2009/03/01,
        2009/03"                    2009/08/01, ...
 
-       If you want intervals that start on arbitrary day of your choosing  and
+       If  you want intervals that start on arbitrary day of your choosing and
        span a week, month or year, you need to use any of the following:
 
        every Nth day of week, every <weekday>, every Nth day [of month], every
@@ -1105,42 +1101,42 @@
        -p  "every  2nd  day  of   periods will go from Tue to Tue
        week"
        -p "every Tue"             same
-       -p "every 15th day"        period boundaries will  be  on  15th  of  each
+       -p "every 15th day"        period  boundaries  will  be  on  15th of each
                                   month
-       -p "every 2nd Monday"      period  boundaries will be on second Monday of
+       -p "every 2nd Monday"      period boundaries will be on second Monday  of
                                   each month
        -p "every 11/05"           yearly periods with boundaries on 5th of Nov
        -p "every 5th Nov"         same
        -p "every Nov 5th"         same
 
-       Show historical balances at end of 15th each month (N is exclusive  end
+       Show  historical balances at end of 15th each month (N is exclusive end
        date):
 
        hledger balance -H -p "every 16th day"
 
-       Group  postings  from  start  of wednesday to end of next tuesday (N is
+       Group postings from start of wednesday to end of  next  tuesday  (N  is
        start date and exclusive end date):
 
        hledger register checking -p "every 3rd day of week"
 
    Depth limiting
        With the --depth N option (short form: -N), commands like account, bal-
-       ance  and register will show only the uppermost accounts in the account
-       tree, down to level N.  Use this when you want a summary with less  de-
+       ance and register will show only the uppermost accounts in the  account
+       tree,  down to level N.  Use this when you want a summary with less de-
        tail.  This flag has the same effect as a depth: query argument (so -2,
-       --depth=2 or depth:2 are basically equivalent).
+       --depth=2 or depth:2 are equivalent).
 
    Pivoting
        Normally hledger sums amounts, and organizes them in a hierarchy, based
-       on  account  name.  The --pivot FIELD option causes it to sum and orga-
-       nize hierarchy based on the value of some other field  instead.   FIELD
+       on account name.  The --pivot FIELD option causes it to sum  and  orga-
+       nize  hierarchy  based on the value of some other field instead.  FIELD
        can be: code, description, payee, note, or the full name (case insensi-
        tive) of any tag.  As with account names, values containing colon:sepa-
        rated:parts will be displayed hierarchically in reports.
 
-       --pivot  is  a  general  option affecting all reports; you can think of
+       --pivot is a general option affecting all reports;  you  can  think  of
        hledger transforming the journal before any other processing, replacing
-       every  posting's  account name with the value of the specified field on
+       every posting's account name with the value of the specified  field  on
        that posting, inheriting it from the transaction or using a blank value
        if it's not present.
 
@@ -1166,7 +1162,7 @@
               --------------------
                                  0
 
-       One  way  to show only amounts with a member: value (using a query, de-
+       One way to show only amounts with a member: value (using a  query,  de-
        scribed below):
 
               $ hledger balance --pivot member tag:member=.
@@ -1174,7 +1170,7 @@
               --------------------
                             -2 EUR
 
-       Another way (the acct:  query  matches  against  the  pivoted  "account
+       Another  way  (the  acct:  query  matches  against the pivoted "account
        name"):
 
               $ hledger balance --pivot member acct:.
@@ -1183,28 +1179,44 @@
                             -2 EUR
 
    Valuation
+       hledger can show cost reports, where amounts  are  converted  to  their
+       cost  or  sale  amount  at  transaction  time;  or value reports, where
+       amounts are converted to their market value in another currency/commod-
+       ity  at a specified date (using market prices inferred from your trans-
+       actions, or declared with P directives).
+
+       We call this "valuation", and it is controlled  by  the  --value=VALUA-
+       TIONTYPE[,COMMODITY] option.  It can get a little involved, so we cover
+       all the details below.  But most of the time, all you need to do is use
+       these simpler flags instead:
+
+       o -B to convert to cost/sale amount, or
+
+       o -V  to  convert  to market value in your base currency.  Or occasion-
+         ally,
+
+       o -X COMMODITY to convert to market value in some other currency.
+
    -B: Cost
-       The -B/--cost flag converts amounts to their cost (or selling price) at
-       transaction time, if they have a  transaction  price  specified.   This
-       flag is equivalent to --value=cost, described below.
+       The -B/--cost flag converts amounts to their cost  or  sale  amount  at
+       transaction  time,  if they have a transaction price specified.  (It is
+       equivalent to --value=cost.)
 
-   -V: Market value
-       The -V/--market flag converts reported amounts to their market value in
-       a default valuation commodity, using the market prices in effect  on  a
-       default  valuation date.  For single period reports, the valuation date
-       is today (equivalent to --value=now); for multiperiod  reports,  it  is
-       the last day of each subperiod (equivalent to --value=end).
+   -V: Value
+       The -V/--market flag converts reported amounts to market value in their
+       default valuation commodity, using the market prices in effect on a de-
+       fault valuation date.  (More on these below.)
 
        The default valuation commodity is the one referenced in the latest ap-
-       plicable market price dated on or before the valuation date.   If  most
-       of  your  P declarations lead to a single home currency, this will usu-
-       ally be what you want.  (To specify the commodity, see -X below.)
+       plicable market price dated on or before the valuation date.  Typically
+       your P declarations or currency exchange transactions reference a  sin-
+       gle base currency, and -V will pick that.
 
-       Note that in hledger, market prices are always declared explicitly with
-       P  directives;  we  do not infer them from transaction prices as Ledger
-       does.
+       The  default valuation date is today for single period reports (equiva-
+       lent to --value=now), or the last day of each subperiod for multiperiod
+       reports (equivalent to --value=end).
 
-       Here's a quick example of -V:
+       An example:
 
               ; one euro is worth this many dollars from nov 1
               P 2016/11/01 EUR $1.10
@@ -1227,17 +1239,39 @@
               $ hledger -f t.j bal -N euros -V -e 2016/11/4
                            $110.00  assets:euros
 
-       What are they worth after 2016/12/21 ?  (no report end date  specified,
+       What  are they worth after 2016/12/21 ?  (no report end date specified,
        defaults to today)
 
               $ hledger -f t.j bal -N euros -V
                            $103.00  assets:euros
 
    -X: Market value in specified commodity
-       The  -X/--exchange  option  is  like -V, except it specifies the target
-       commodity  you  would  like  to  convert  to.   It  is  equivalent   to
-       --value=now,COMM or --value=end,COMM.
+       The -X/--exchange option is like -V, except  it  specifies  the  target
+       commodity  you  would  like  to  convert  to.   (It  is  equivalent  to
+       --value=now,COMM or --value=end,COMM.)
 
+   Market prices
+       To convert a commodity A to commodity B, hledger looks for  a  suitable
+       market  price  (exchange  rate) in the following ways, in this order of
+       preference:
+
+       1. a declared market price - the latest P directive specifying the  ex-
+          change rate from A to B, dated on or before the valuation date.
+
+       2. a  transaction-implied  market  price  - a market price matching the
+          transaction price used in the latest transaction  where  A  is  con-
+          verted  to B, dated on or before the valuation date.  (since hledger
+          1.18; experimental)
+
+       3. a reverse declared market price - calculated by inverting a declared
+          market price from B to A.
+
+       4. a reverse transaction-implied market price - calculated by inverting
+          a transaction-implied market price from B to A.
+
+       5. an indirect market price -  calculated  by  combining  the  shortest
+          chain of market prices (any of the above types) leading from A to B.
+
    --value: Flexible valuation
        (experimental, added 201905)
 
@@ -1414,7 +1448,6 @@
        Report type    -B,            -V, -X         --value=then    --value=end    --value=DATE,
                       --value=cost                                                 --value=now
        ------------------------------------------------------------------------------------------
-
        print
        posting        cost           value at re-   value      at   value at re-   value      at
        amounts                       port end  or   posting date    port      or   DATE/today
@@ -1459,6 +1492,9 @@
        (with report   postings be-   fore  report                   fore  report   report start
        interval and   fore  report   start                          start
        -H)            start
+
+
+
        budget         like    bal-   like    bal-   not supported   like    bal-   like balances
        amounts with   ances          ances                          ances
        --budget
@@ -1508,9 +1544,6 @@
               report's multi-period mode (whether showing one or many subperi-
               ods).
 
-   Combining -B, -V, -X, --value
-       The rightmost of these flags wins.
-
 COMMANDS
        hledger  provides  a  number  of subcommands; hledger with no arguments
        shows a list.
@@ -1995,27 +2028,28 @@
               ----------------------++----------------------------------------------------
                                     ||      0 [              0]       0 [              0]
 
-       Note this is different from a normal balance report in several ways:
+       This is different from a normal balance report in several ways:
 
        o Only  accounts  with budget goals during the report period are shown,
          by default.
 
-       o In each column, in square brackets after the actual amount,  budgeted
-         amounts are shown, along with the percentage of budget used.
+       o In each column, in square brackets after the  actual  amount,  budget
+         goal  amounts are shown, and the actual/goal percentage.  (Note: bud-
+         get goals should be in the same commodity as the actual amount.)
 
-       o All  parent accounts are always shown, even in flat mode.  Eg assets,
+       o All parent accounts are always shown, even in flat mode.  Eg  assets,
          assets:bank, and expenses above.
 
-       o Amounts always include all subaccounts, budgeted or unbudgeted,  even
+       o Amounts  always include all subaccounts, budgeted or unbudgeted, even
          in flat mode.
 
        This means that the numbers displayed will not always add up! Eg above,
-       the expenses actual amount includes the  gifts  and  supplies  transac-
-       tions,  but  the  expenses:gifts and expenses:supplies accounts are not
+       the  expenses  actual  amount  includes the gifts and supplies transac-
+       tions, but the expenses:gifts and expenses:supplies  accounts  are  not
        shown, as they have no budget amounts declared.
 
-       This can be confusing.  When you need to make things clearer,  use  the
-       -E/--empty  flag,  which  will reveal all accounts including unbudgeted
+       This  can  be confusing.  When you need to make things clearer, use the
+       -E/--empty flag, which will reveal all  accounts  including  unbudgeted
        ones, giving the full picture.  Eg:
 
               $ hledger balance -M --budget --empty
@@ -2057,12 +2091,12 @@
        For more examples, see Budgeting and Forecasting.
 
    Nested budgets
-       You can add budgets to any account in your account hierarchy.   If  you
+       You  can  add budgets to any account in your account hierarchy.  If you
        have budgets on both parent account and some of its children, then bud-
-       get(s) of the child account(s) would be added to the  budget  of  their
+       get(s)  of  the  child account(s) would be added to the budget of their
        parent, much like account balances behave.
 
-       In  the  most  simple case this means that once you add a budget to any
+       In the most simple case this means that once you add a  budget  to  any
        account, all its parents would have budget as well.
 
        To illustrate this, consider the following budget:
@@ -2072,13 +2106,13 @@
                   expenses:personal:electronics    $100.00
                   liabilities
 
-       With this, monthly budget for electronics is defined  to  be  $100  and
-       budget  for  personal expenses is an additional $1000, which implicitly
+       With  this,  monthly  budget  for electronics is defined to be $100 and
+       budget for personal expenses is an additional $1000,  which  implicitly
        means that budget for both expenses:personal and expenses is $1100.
 
-       Transactions in expenses:personal:electronics will be counted both  to-
+       Transactions  in expenses:personal:electronics will be counted both to-
        wards its $100 budget and $1100 of expenses:personal , and transactions
-       in any other subaccount of expenses:personal would be  counted  towards
+       in  any  other subaccount of expenses:personal would be counted towards
        only towards the budget of expenses:personal.
 
        For example, let's consider these transactions:
@@ -2104,9 +2138,9 @@
                   expenses:personal          $30.00
                   liabilities
 
-       As  you  can  see,  we have transactions in expenses:personal:electron-
-       ics:upgrades and expenses:personal:train tickets,  and  since  both  of
-       these  accounts  are  without explicitly defined budget, these transac-
+       As you can see, we  have  transactions  in  expenses:personal:electron-
+       ics:upgrades  and  expenses:personal:train  tickets,  and since both of
+       these accounts are without explicitly defined  budget,  these  transac-
        tions would be counted towards budgets of expenses:personal:electronics
        and expenses:personal accordingly:
 
@@ -2122,7 +2156,7 @@
               -------------------------------++-------------------------------
                                              ||        0 [                 0]
 
-       And  with --empty, we can get a better picture of budget allocation and
+       And with --empty, we can get a better picture of budget allocation  and
        consumption:
 
               $ hledger balance --budget -M --empty
@@ -2141,17 +2175,17 @@
 
    Output format
        This command also supports the output destination and output format op-
-       tions  The output formats supported are txt, csv, (multicolumn non-bud-
+       tions The output formats supported are txt, csv, (multicolumn  non-bud-
        get reports only) html, and (experimental) json.
 
    balancesheet
        balancesheet, bs
        This command displays a simple balance sheet, showing historical ending
-       balances  of  asset  and  liability accounts (ignoring any report begin
-       date).  It assumes that these accounts are under a top-level  asset  or
+       balances of asset and liability accounts  (ignoring  any  report  begin
+       date).   It  assumes that these accounts are under a top-level asset or
        liability account (case insensitive, plural forms also allowed).
 
-       Note  this  report shows all account balances with normal positive sign
+       Note this report shows all account balances with normal  positive  sign
        (like conventional financial statements, unlike balance/print/register)
        (experimental).
 
@@ -2177,21 +2211,21 @@
                                  0
 
        With a reporting interval, multiple columns will be shown, one for each
-       report period.  As with multicolumn balance reports, you can alter  the
-       report  mode  with  --change/--cumulative/--historical.   Normally bal-
-       ancesheet shows historical ending balances, which is what you need  for
-       a  balance  sheet;  note  this means it ignores report begin dates (and
-       -T/--row-total, since summing end  balances  generally  does  not  make
-       sense).   Instead  of absolute values percentages can be displayed with
+       report  period.  As with multicolumn balance reports, you can alter the
+       report mode  with  --change/--cumulative/--historical.   Normally  bal-
+       ancesheet  shows historical ending balances, which is what you need for
+       a balance sheet; note this means it ignores  report  begin  dates  (and
+       -T/--row-total,  since  summing  end  balances  generally does not make
+       sense).  Instead of absolute values percentages can be  displayed  with
        -%.
 
        This command also supports the output destination and output format op-
-       tions  The output formats supported are txt, csv, html, and (experimen-
+       tions The output formats supported are txt, csv, html, and  (experimen-
        tal) json.
 
    balancesheetequity
        balancesheetequity, bse
-       Just like balancesheet, but also reports Equity (which  it  assumes  is
+       Just  like  balancesheet,  but also reports Equity (which it assumes is
        under a top-level equity account).
 
        Example:
@@ -2221,15 +2255,15 @@
                                  0
 
        This command also supports the output destination and output format op-
-       tions The output formats supported are txt, csv, html, and  (experimen-
+       tions  The output formats supported are txt, csv, html, and (experimen-
        tal) json.
 
    cashflow
        cashflow, cf
-       This  command  displays a simple cashflow statement, showing changes in
-       "cash" accounts.  It assumes that these accounts are under a  top-level
-       asset  account (case insensitive, plural forms also allowed) and do not
-       contain receivable or A/R in their name.  Note this  report  shows  all
+       This command displays a simple cashflow statement, showing  changes  in
+       "cash"  accounts.  It assumes that these accounts are under a top-level
+       asset account (case insensitive, plural forms also allowed) and do  not
+       contain  receivable  or  A/R in their name.  Note this report shows all
        account balances with normal positive sign (like conventional financial
        statements, unlike balance/print/register) (experimental).
 
@@ -2250,90 +2284,90 @@
                                $-1
 
        With a reporting interval, multiple columns will be shown, one for each
-       report  period.   Normally cashflow shows changes in assets per period,
-       though as with multicolumn balance reports you  can  alter  the  report
+       report period.  Normally cashflow shows changes in assets  per  period,
+       though  as  with  multicolumn  balance reports you can alter the report
        mode with --change/--cumulative/--historical.  Instead of absolute val-
        ues percentages can be displayed with -%.
 
        This command also supports the output destination and output format op-
-       tions  The output formats supported are txt, csv, html, and (experimen-
+       tions The output formats supported are txt, csv, html, and  (experimen-
        tal) json.
 
    check-dates
        check-dates
-       Check that transactions are sorted by increasing date.   With  --date2,
-       checks  secondary  dates  instead.   With  --strict, dates must also be
-       unique.  With a query, only matched transactions'  dates  are  checked.
+       Check  that  transactions are sorted by increasing date.  With --date2,
+       checks secondary dates instead.  With  --strict,  dates  must  also  be
+       unique.   With  a  query, only matched transactions' dates are checked.
        Reads the default journal file, or another specified with -f.
 
    check-dupes
        check-dupes
-       Reports  account names having the same leaf but different prefixes.  In
-       other words, two or  more  leaves  that  are  categorized  differently.
+       Reports account names having the same leaf but different prefixes.   In
+       other  words,  two  or  more  leaves  that are categorized differently.
        Reads the default journal file, or another specified as an argument.
 
        An example: http://stefanorodighiero.net/software/hledger-dupes.html
 
    close
        close, equity
-       Prints  a  "closing  balances"  transaction  and  an "opening balances"
+       Prints a "closing  balances"  transaction  and  an  "opening  balances"
        transaction that bring account balances to and from zero, respectively.
        These can be added to your journal file(s), eg to bring asset/liability
-       balances forward into a new journal file, or to close out  revenues/ex-
+       balances  forward into a new journal file, or to close out revenues/ex-
        penses to retained earnings at the end of a period.
 
-       You  can  print  just one of these transactions by using the --close or
-       --open flag.  You can customise their descriptions  with  the  --close-
+       You can print just one of these transactions by using  the  --close  or
+       --open  flag.   You  can customise their descriptions with the --close-
        desc and --open-desc options.
 
        One amountless posting to "equity:opening/closing balances" is added to
-       balance the transactions, by default.  You can customise  this  account
-       name  with  --close-acct  and  --open-acct;  if you specify only one of
+       balance  the  transactions, by default.  You can customise this account
+       name with --close-acct and --open-acct; if  you  specify  only  one  of
        these, it will be used for both.
 
        With --x/--explicit, the equity posting's amount will be shown.  And if
-       it  involves multiple commodities, a posting for each commodity will be
+       it involves multiple commodities, a posting for each commodity will  be
        shown, as with the print command.
 
-       With --interleaved, the equity postings are shown next to the  postings
+       With  --interleaved, the equity postings are shown next to the postings
        they balance, which makes troubleshooting easier.
 
        By default, transaction prices in the journal are ignored when generat-
        ing the closing/opening transactions.  With --show-costs, this cost in-
-       formation  is preserved (balance -B reports will be unchanged after the
-       transition).  Separate postings are generated for  each  cost  in  each
-       commodity.   Note  this can generate very large journal entries, if you
+       formation is preserved (balance -B reports will be unchanged after  the
+       transition).   Separate  postings  are  generated for each cost in each
+       commodity.  Note this can generate very large journal entries,  if  you
        have many foreign currency or investment transactions.
 
    close usage
        If you split your journal files by time (eg yearly), you will typically
-       run  this command at the end of the year, and save the closing transac-
-       tion as last entry of the old file, and the opening transaction as  the
-       first  entry  of the new file.  This makes the files self contained, so
-       that correct balances are reported no matter which of them are  loaded.
-       Ie,  if you load just one file, the balances are initialised correctly;
-       or if you load several files, the  redundant  closing/opening  transac-
-       tions  cancel  each other out.  (They will show up in print or register
-       reports; you can  exclude  them  with  a  query  like  not:desc:'(open-
+       run this command at the end of the year, and save the closing  transac-
+       tion  as last entry of the old file, and the opening transaction as the
+       first entry of the new file.  This makes the files self  contained,  so
+       that  correct balances are reported no matter which of them are loaded.
+       Ie, if you load just one file, the balances are initialised  correctly;
+       or  if  you  load several files, the redundant closing/opening transac-
+       tions cancel each other out.  (They will show up in print  or  register
+       reports;  you  can  exclude  them  with  a  query like not:desc:'(open-
        ing|closing) balances'.)
 
        If you're running a business, you might also use this command to "close
-       the books" at the end of  an  accounting  period,  transferring  income
-       statement  account  balances  to  retained  earnings.  (You may want to
+       the  books"  at  the  end  of an accounting period, transferring income
+       statement account balances to retained  earnings.   (You  may  want  to
        change the equity account name to something like "equity:retained earn-
        ings".)
 
-       By  default,  the  closing transaction is dated yesterday, the balances
-       are calculated as of end of yesterday, and the opening  transaction  is
-       dated  today.  To close on some other date, use: hledger close -e OPEN-
-       INGDATE.  Eg, to close/open on the 2018/2019  boundary,  use  -e  2019.
+       By default, the closing transaction is dated  yesterday,  the  balances
+       are  calculated  as of end of yesterday, and the opening transaction is
+       dated today.  To close on some other date, use: hledger close -e  OPEN-
+       INGDATE.   Eg,  to  close/open  on the 2018/2019 boundary, use -e 2019.
        You can also use -p or date:PERIOD (any starting date is ignored).
 
-       Both  transactions  will  include balance assertions for the closed/re-
+       Both transactions will include balance assertions  for  the  closed/re-
        opened accounts.  You probably shouldn't use status or realness filters
-       (like  -C or -R or status:) with this command, or the generated balance
-       assertions will depend on these flags.  Likewise, if you run this  com-
-       mand  with  --auto, the balance assertions will probably always require
+       (like -C or -R or status:) with this command, or the generated  balance
+       assertions  will depend on these flags.  Likewise, if you run this com-
+       mand with --auto, the balance assertions will probably  always  require
        --auto.
 
        Examples:
@@ -2388,18 +2422,18 @@
 
    diff
        diff
-       Compares  a  particular  account's transactions in two input files.  It
+       Compares a particular account's transactions in two  input  files.   It
        shows any transactions to this account which are in one file but not in
        the other.
 
        More precisely, for each posting affecting this account in either file,
-       it looks for a corresponding posting in the other file which posts  the
-       same  amount  to  the  same  account (ignoring date, description, etc.)
+       it  looks for a corresponding posting in the other file which posts the
+       same amount to the same  account  (ignoring  date,  description,  etc.)
        Since postings not transactions are compared, this also works when mul-
        tiple bank transactions have been combined into a single journal entry.
 
        This is useful eg if you have downloaded an account's transactions from
-       your bank (eg as CSV data).  When hledger and your bank disagree  about
+       your  bank (eg as CSV data).  When hledger and your bank disagree about
        the account balance, you can compare the bank data with your journal to
        find out the cause.
 
@@ -2417,20 +2451,20 @@
 
    files
        files
-       List all files included in the journal.  With a  REGEX  argument,  only
+       List  all  files  included in the journal.  With a REGEX argument, only
        file names matching the regular expression (case sensitive) are shown.
 
    help
        help
        Show any of the hledger manuals.
 
-       The  help  command  displays any of the main hledger manuals, in one of
-       several ways.  Run it with no argument to list the manuals, or  provide
+       The help command displays any of the main hledger manuals,  in  one  of
+       several  ways.  Run it with no argument to list the manuals, or provide
        a full or partial manual name to select one.
 
-       hledger  manuals  are  available in several formats.  hledger help will
-       use the first of these  display  methods  that  it  finds:  info,  man,
-       $PAGER,  less,  stdout (or when non-interactive, just stdout).  You can
+       hledger manuals are available in several formats.   hledger  help  will
+       use  the  first  of  these  display  methods  that it finds: info, man,
+       $PAGER, less, stdout (or when non-interactive, just stdout).   You  can
        force a particular viewer with the --info, --man, --pager, --cat flags.
 
        Examples:
@@ -2457,9 +2491,9 @@
 
    import
        import
-       Read new transactions added to each FILE since last run, and  add  them
-       to  the  main journal file.  Or with --dry-run, just print the transac-
-       tions that would be added.  Or with --catchup, just  mark  all  of  the
+       Read  new  transactions added to each FILE since last run, and add them
+       to the main journal file.  Or with --dry-run, just print  the  transac-
+       tions  that  would  be  added.  Or with --catchup, just mark all of the
        FILEs' transactions as imported, without actually importing any.
 
        The input files are specified as arguments - no need to write -f before
@@ -2470,36 +2504,36 @@
        ing transactions are always added to the input files in increasing date
        order, and by saving .latest.FILE state files.
 
-       The  --dry-run output is in journal format, so you can filter it, eg to
+       The --dry-run output is in journal format, so you can filter it, eg  to
        see only uncategorised transactions:
 
               $ hledger import --dry ... | hledger -f- print unknown --ignore-assertions
 
    Importing balance assignments
-       Entries added by import will have their posting amounts  made  explicit
-       (like  hledger  print  -x).  This means that any balance assignments in
-       imported files must be evaluated; but, imported files don't get to  see
-       the  main file's account balances.  As a result, importing entries with
+       Entries  added  by import will have their posting amounts made explicit
+       (like hledger print -x).  This means that any  balance  assignments  in
+       imported  files must be evaluated; but, imported files don't get to see
+       the main file's account balances.  As a result, importing entries  with
        balance assignments (eg from an institution that provides only balances
-       and  not  posting  amounts)  will  probably  generate incorrect posting
+       and not posting  amounts)  will  probably  generate  incorrect  posting
        amounts.  To avoid this problem, use print instead of import:
 
               $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE
 
-       (If you think import should leave amounts  implicit  like  print  does,
+       (If  you  think  import  should leave amounts implicit like print does,
        please test it and send a pull request.)
 
    incomestatement
        incomestatement, is
-       This  command  displays a simple income statement, showing revenues and
-       expenses during a period.  It assumes that these accounts are  under  a
-       top-level  revenue or income or expense account (case insensitive, plu-
-       ral forms also allowed).  Note this report shows all  account  balances
-       with  normal positive sign (like conventional financial statements, un-
+       This command displays a simple income statement, showing  revenues  and
+       expenses  during  a period.  It assumes that these accounts are under a
+       top-level revenue or income or expense account (case insensitive,  plu-
+       ral  forms  also allowed).  Note this report shows all account balances
+       with normal positive sign (like conventional financial statements,  un-
        like balance/print/register) (experimental).
 
-       This command displays a simple income statement.  It currently  assumes
-       that  you have top-level accounts named income (or revenue) and expense
+       This  command displays a simple income statement.  It currently assumes
+       that you have top-level accounts named income (or revenue) and  expense
        (plural forms also allowed.)
 
               $ hledger incomestatement
@@ -2524,13 +2558,13 @@
                                  0
 
        With a reporting interval, multiple columns will be shown, one for each
-       report  period.   Normally  incomestatement shows revenues/expenses per
-       period, though as with multicolumn balance reports you  can  alter  the
-       report  mode with --change/--cumulative/--historical.  Instead of abso-
+       report period.  Normally incomestatement  shows  revenues/expenses  per
+       period,  though  as  with multicolumn balance reports you can alter the
+       report mode with --change/--cumulative/--historical.  Instead of  abso-
        lute values percentages can be displayed with -%.
 
        This command also supports the output destination and output format op-
-       tions  The output formats supported are txt, csv, html, and (experimen-
+       tions The output formats supported are txt, csv, html, and  (experimen-
        tal) json.
 
    notes
@@ -2558,10 +2592,10 @@
 
    prices
        prices
-       Print market price directives from the  journal.   With  --costs,  also
-       print  synthetic market prices based on transaction prices.  With --in-
-       verted-costs, also print inverse prices based  on  transaction  prices.
-       Prices  (and  postings  providing  prices)  can be filtered by a query.
+       Print  market  price  directives  from the journal.  With --costs, also
+       print synthetic market prices based on transaction prices.  With  --in-
+       verted-costs,  also  print  inverse prices based on transaction prices.
+       Prices (and postings providing prices) can  be  filtered  by  a  query.
        Price amounts are always displayed with their full precision.
 
    print
@@ -2569,11 +2603,11 @@
        Show transaction journal entries, sorted by date.
 
        The print command displays full journal entries (transactions) from the
-       journal  file  in date order, tidily formatted.  With --date2, transac-
+       journal file in date order, tidily formatted.  With  --date2,  transac-
        tions are sorted by secondary date instead.
 
        print's output is always a valid hledger journal.
-       It preserves all transaction information, but it does not preserve  di-
+       It  preserves all transaction information, but it does not preserve di-
        rectives or inter-transaction comments
 
               $ hledger print
@@ -2600,43 +2634,43 @@
 
        Normally, the journal entry's explicit or implicit amount style is pre-
        served.  For example, when an amount is omitted in the journal, it will
-       not  appear  in the output.  Similarly, when a transaction price is im-
-       plied but not written, it will not appear in the output.  You  can  use
-       the  -x/--explicit  flag to make all amounts and transaction prices ex-
-       plicit, which can be useful for  troubleshooting  or  for  making  your
+       not appear in the output.  Similarly, when a transaction price  is  im-
+       plied  but  not written, it will not appear in the output.  You can use
+       the -x/--explicit flag to make all amounts and transaction  prices  ex-
+       plicit,  which  can  be  useful  for troubleshooting or for making your
        journal more readable and robust against data entry errors.  -x is also
        implied by using any of -B,-V,-X,--value.
 
-       Note, -x/--explicit will cause postings with a  multi-commodity  amount
-       (these  can  arise  when  a multi-commodity transaction has an implicit
-       amount) to be split into multiple  single-commodity  postings,  keeping
+       Note,  -x/--explicit  will cause postings with a multi-commodity amount
+       (these can arise when a multi-commodity  transaction  has  an  implicit
+       amount)  to  be  split into multiple single-commodity postings, keeping
        the output parseable.
 
-       With  -B/--cost,  amounts with transaction prices are converted to cost
+       With -B/--cost, amounts with transaction prices are converted  to  cost
        using that price.  This can be used for troubleshooting.
 
-       With -m/--match and a STR argument, print will show at most one  trans-
-       action:  the  one  one whose description is most similar to STR, and is
-       most recent.  STR should contain at least two characters.  If there  is
+       With  -m/--match and a STR argument, print will show at most one trans-
+       action: the one one whose description is most similar to  STR,  and  is
+       most  recent.  STR should contain at least two characters.  If there is
        no similar-enough match, no transaction will be shown.
 
        With --new, for each FILE being read, hledger reads (and writes) a spe-
-       cial state file (.latest.FILE in the same  directory),  containing  the
-       latest  transaction  date(s)  that  were  seen last time FILE was read.
-       When this file is found, only transactions with newer  dates  (and  new
-       transactions  on  the latest date) are printed.  This is useful for ig-
-       noring already-seen entries in import  data,  such  as  downloaded  CSV
+       cial  state  file  (.latest.FILE in the same directory), containing the
+       latest transaction date(s) that were seen  last  time  FILE  was  read.
+       When  this  file  is found, only transactions with newer dates (and new
+       transactions on the latest date) are printed.  This is useful  for  ig-
+       noring  already-seen  entries  in  import  data, such as downloaded CSV
        files.  Eg:
 
               $ hledger -f bank1.csv print --new
               (shows transactions added since last print --new on this file)
 
-       This  assumes  that  transactions added to FILE always have same or in-
-       creasing dates, and that transactions on the same day do  not  get  re-
+       This assumes that transactions added to FILE always have  same  or  in-
+       creasing  dates,  and  that transactions on the same day do not get re-
        ordered.  See also the import command.
 
        This command also supports the output destination and output format op-
-       tions The output formats supported are  txt,  csv,  and  (experimental)
+       tions  The  output  formats  supported are txt, csv, and (experimental)
        json.
 
        Here's an example of print's CSV output:
@@ -2655,20 +2689,20 @@
               "5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","",""
               "5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","",""
 
-       o There  is  one  CSV record per posting, with the parent transaction's
+       o There is one CSV record per posting, with  the  parent  transaction's
          fields repeated.
 
        o 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
+         the same transaction.  (This number might change if transactions  are
+         reordered  within  the file, files are parsed/included in a different
          order, etc.)
 
-       o The  amount  is  separated into "commodity" (the symbol) and "amount"
+       o The amount is separated into "commodity" (the  symbol)  and  "amount"
          (numeric quantity) fields.
 
        o The numeric amount is repeated in either the "credit" or "debit" col-
-         umn,  for convenience.  (Those names are not accurate in the account-
-         ing sense; it just puts negative amounts under  credit  and  zero  or
+         umn, for convenience.  (Those names are not accurate in the  account-
+         ing  sense;  it  just  puts negative amounts under credit and zero or
          greater amounts under debit.)
 
    print-unique
@@ -2692,7 +2726,7 @@
        Show postings and their running total.
 
        The register command displays postings in date order, one per line, and
-       their running total.  This is typically used with a query  selecting  a
+       their  running  total.  This is typically used with a query selecting a
        particular account, to see that account's activity:
 
               $ hledger register checking
@@ -2703,8 +2737,8 @@
 
        With --date2, it shows and sorts by secondary date instead.
 
-       The  --historical/-H  flag  adds the balance from any undisplayed prior
-       postings to the running total.  This is useful when  you  want  to  see
+       The --historical/-H flag adds the balance from  any  undisplayed  prior
+       postings  to  the  running  total.  This is useful when you want to see
        only recent activity, with a historically accurate running balance:
 
               $ hledger register checking -b 2008/6 --historical
@@ -2714,18 +2748,18 @@
 
        The --depth option limits the amount of sub-account detail displayed.
 
-       The  --average/-A flag shows the running average posting amount instead
+       The --average/-A flag shows the running average posting amount  instead
        of the running total (so, the final number displayed is the average for
-       the  whole  report period).  This flag implies --empty (see below).  It
-       is affected by --historical.  It works best when showing just  one  ac-
+       the whole report period).  This flag implies --empty (see  below).   It
+       is  affected  by --historical.  It works best when showing just one ac-
        count and one commodity.
 
-       The  --related/-r  flag shows the other postings in the transactions of
+       The --related/-r flag shows the other postings in the  transactions  of
        the postings which would normally be shown.
 
-       The --invert flag negates all amounts.  For example, it can be used  on
+       The  --invert flag negates all amounts.  For example, it can be used on
        an income account where amounts are normally displayed as negative num-
-       bers.  It's also useful to show postings on the  checking  account  to-
+       bers.   It's  also  useful to show postings on the checking account to-
        gether with the related account:
 
               $ hledger register --related --invert assets:checking
@@ -2737,7 +2771,7 @@
               2008/01                 income:salary                          $-1          $-1
               2008/06                 income:gifts                           $-1          $-2
 
-       Periods with no activity, and summary postings with a zero amount,  are
+       Periods  with no activity, and summary postings with a zero amount, are
        not shown by default; use the --empty/-E flag to see them:
 
               $ hledger register --monthly income -E
@@ -2754,7 +2788,7 @@
               2008/11                                                          0          $-2
               2008/12                                                          0          $-2
 
-       Often,  you'll want to see just one line per interval.  The --depth op-
+       Often, you'll want to see just one line per interval.  The --depth  op-
        tion helps with this, causing subaccounts to be aggregated:
 
               $ hledger register --monthly assets --depth 1h
@@ -2762,17 +2796,17 @@
               2008/06                 assets                                 $-1            0
               2008/12                 assets                                 $-1          $-1
 
-       Note when using report intervals, if you specify start/end dates  these
-       will  be adjusted outward if necessary to contain a whole number of in-
-       tervals.  This ensures that the  first  and  last  intervals  are  full
+       Note  when using report intervals, if you specify start/end dates these
+       will be adjusted outward if necessary to contain a whole number of  in-
+       tervals.   This  ensures  that  the  first  and last intervals are full
        length and comparable to the others in the report.
 
    Custom register output
-       register  uses  the  full terminal width by default, except on windows.
-       You can override this by setting the COLUMNS environment variable  (not
+       register uses the full terminal width by default,  except  on  windows.
+       You  can override this by setting the COLUMNS environment variable (not
        a bash shell variable) or by using the --width/-w option.
 
-       The  description  and  account columns normally share the space equally
+       The description and account columns normally share  the  space  equally
        (about half of (width - 40) each).  You can adjust this by adding a de-
        scription width as part of --width's argument, comma-separated: --width
        W,D .  Here's a diagram (won't display correctly in --help):
@@ -2791,27 +2825,27 @@
               $ hledger reg -w $COLUMNS,40      # use terminal width, & description width 40
 
        This command also supports the output destination and output format op-
-       tions  The  output  formats  supported are txt, csv, and (experimental)
+       tions The output formats supported are  txt,  csv,  and  (experimental)
        json.
 
    register-match
        register-match
        Print the one posting whose transaction description is closest to DESC,
-       in  the  style  of the register command.  If there are multiple equally
-       good matches, it shows the most recent.  Query  options  (options,  not
-       arguments)  can be used to restrict the search space.  Helps ledger-au-
+       in the style of the register command.  If there  are  multiple  equally
+       good  matches,  it  shows the most recent.  Query options (options, not
+       arguments) can be used to restrict the search space.  Helps  ledger-au-
        tosync detect already-seen transactions when importing.
 
    rewrite
        rewrite
        Print all transactions, rewriting the postings of matched transactions.
-       For  now  the only rewrite available is adding new postings, like print
+       For now the only rewrite available is adding new postings,  like  print
        --auto.
 
        This is a start at a generic rewriter of transaction entries.  It reads
-       the  default  journal and prints the transactions, like print, but adds
+       the default journal and prints the transactions, like print,  but  adds
        one or more specified postings to any transactions matching QUERY.  The
-       posting  amounts can be fixed, or a multiplier of the existing transac-
+       posting amounts can be fixed, or a multiplier of the existing  transac-
        tion's first posting amount.
 
        Examples:
@@ -2827,7 +2861,7 @@
                 (reserve:grocery)  *0.25  ; reserve 25% for grocery
                 (reserve:)  *0.25  ; reserve 25% for grocery
 
-       Note the single quotes to protect the dollar sign from  bash,  and  the
+       Note  the  single  quotes to protect the dollar sign from bash, and the
        two spaces between account and amount.
 
        More:
@@ -2837,16 +2871,16 @@
               $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts)  *-1"'
               $ hledger rewrite -- ^income        --add-posting '(budget:foreign currency)  *0.25 JPY; diversify'
 
-       Argument  for  --add-posting  option  is a usual posting of transaction
-       with an exception for amount specification.  More  precisely,  you  can
+       Argument for --add-posting option is a  usual  posting  of  transaction
+       with  an  exception  for amount specification.  More precisely, you can
        use '*' (star symbol) before the amount to indicate that that this is a
-       factor for an amount of original matched posting.  If  the  amount  in-
+       factor  for  an  amount of original matched posting.  If the amount in-
        cludes a commodity name, the new posting amount will be in the new com-
-       modity; otherwise, it will be in the matched posting  amount's  commod-
+       modity;  otherwise,  it will be in the matched posting amount's commod-
        ity.
 
    Re-write rules in a file
-       During  the  run  this  tool will execute so called "Automated Transac-
+       During the run this tool will execute  so  called  "Automated  Transac-
        tions" found in any journal it process.  I.e instead of specifying this
        operations in command line you can put them in a journal file.
 
@@ -2861,7 +2895,7 @@
                   budget:gifts  *-1
                   assets:budget  *1
 
-       Note  that '=' (equality symbol) that is used instead of date in trans-
+       Note that '=' (equality symbol) that is used instead of date in  trans-
        actions you usually write.  It indicates the query by which you want to
        match the posting to add new ones.
 
@@ -2874,12 +2908,12 @@
                                                               --add-posting 'assets:budget  *1'       \
                 > rewritten-tidy-output.journal
 
-       It  is  important  to understand that relative order of such entries in
-       journal is important.  You can re-use result of previously added  post-
+       It is important to understand that relative order of  such  entries  in
+       journal  is important.  You can re-use result of previously added post-
        ings.
 
    Diff output format
-       To  use  this tool for batch modification of your journal files you may
+       To use this tool for batch modification of your journal files  you  may
        find useful output in form of unified diff.
 
               $ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax)  *.33'
@@ -2903,10 +2937,10 @@
 
        If you'll pass this through patch tool you'll get transactions contain-
        ing the posting that matches your query be updated.  Note that multiple
-       files might be update according to list of input  files  specified  via
+       files  might  be  update according to list of input files specified via
        --file options and include directives inside of these files.
 
-       Be  careful.  Whole transaction being re-formatted in a style of output
+       Be careful.  Whole transaction being re-formatted in a style of  output
        from hledger print.
 
        See also:
@@ -2914,48 +2948,48 @@
        https://github.com/simonmichael/hledger/issues/99
 
    rewrite vs. print --auto
-       This command predates print --auto, and currently does  much  the  same
+       This  command  predates  print --auto, and currently does much the same
        thing, but with these differences:
 
-       o with  multiple files, rewrite lets rules in any file affect all other
-         files.  print --auto uses standard directive  scoping;  rules  affect
+       o with multiple files, rewrite lets rules in any file affect all  other
+         files.   print  --auto  uses standard directive scoping; rules affect
          only child files.
 
-       o rewrite's  query  limits which transactions can be rewritten; all are
+       o rewrite's query limits which transactions can be rewritten;  all  are
          printed.  print --auto's query limits which transactions are printed.
 
-       o rewrite applies rules specified on command line or  in  the  journal.
+       o rewrite  applies  rules  specified on command line or in the journal.
          print --auto applies rules specified in the journal.
 
    roi
        roi
-       Shows  the  time-weighted (TWR) and money-weighted (IRR) rate of return
+       Shows the time-weighted (TWR) and money-weighted (IRR) rate  of  return
        on your investments.
 
-       This command assumes that you have account(s)  that  hold  nothing  but
+       This  command  assumes  that  you have account(s) that hold nothing but
        your investments and whenever you record current appraisal/valuation of
        these investments you offset unrealized profit and loss into account(s)
        that, again, hold nothing but unrealized profit and loss.
 
-       Any  transactions  affecting  balance  of investment account(s) and not
-       originating from unrealized profit and loss account(s) are  assumed  to
+       Any transactions affecting balance of  investment  account(s)  and  not
+       originating  from  unrealized profit and loss account(s) are assumed to
        be your investments or withdrawals.
 
-       At  a  minimum,  you need to supply a query (which could be just an ac-
+       At a minimum, you need to supply a query (which could be  just  an  ac-
        count name) to select your investments with --inv, and another query to
        identify your profit and loss transactions with --pnl.
 
-       It  will  compute and display the internalized rate of return (IRR) and
-       time-weighted rate of return (TWR) for your investments  for  the  time
-       period  requested.  Both rates of return are annualized before display,
+       It will compute and display the internalized rate of return  (IRR)  and
+       time-weighted  rate  of  return (TWR) for your investments for the time
+       period requested.  Both rates of return are annualized before  display,
        regardless of the length of reporting interval.
 
    stats
        stats
        Show some journal statistics.
 
-       The stats command displays summary information for the  whole  journal,
-       or  a matched part of it.  With a reporting interval, it shows a report
+       The  stats  command displays summary information for the whole journal,
+       or a matched part of it.  With a reporting interval, it shows a  report
        for each report period.
 
        Example:
@@ -2973,14 +3007,14 @@
               Commodities              : 1 ($)
               Market prices            : 12 ($)
 
-       This command also supports output destination and output format  selec-
+       This  command also supports output destination and output format selec-
        tion.
 
    tags
        tags
-       List  all the tag names used in the journal.  With a TAGREGEX argument,
-       only tag names matching the regular expression (case  insensitive)  are
-       shown.   With QUERY arguments, only transactions matching the query are
+       List all the tag names used in the journal.  With a TAGREGEX  argument,
+       only  tag  names matching the regular expression (case insensitive) are
+       shown.  With QUERY arguments, only transactions matching the query  are
        considered.  With --values flag, the tags' unique values are listed in-
        stead.
 
@@ -2988,13 +3022,13 @@
        test
        Run built-in unit tests.
 
-       This  command  runs the unit tests built in to hledger and hledger-lib,
-       printing the results on stdout.  If any test fails, the exit code  will
+       This command runs the unit tests built in to hledger  and  hledger-lib,
+       printing  the results on stdout.  If any test fails, the exit code will
        be non-zero.
 
-       This  is  mainly used by hledger developers, but you can also use it to
-       sanity-check the installed hledger executable on  your  platform.   All
-       tests  are  expected to pass - if you ever see a failure, please report
+       This is mainly used by hledger developers, but you can also use  it  to
+       sanity-check  the  installed  hledger executable on your platform.  All
+       tests are expected to pass - if you ever see a failure,  please  report
        as a bug!
 
        This command also accepts tasty test runner options, written after a --
@@ -3003,35 +3037,35 @@
 
               $ hledger test -- -pData.Amount --color=never
 
-       For help on these, see  https://github.com/feuerbach/tasty#options  (--
+       For  help  on these, see https://github.com/feuerbach/tasty#options (--
        --help currently doesn't show them).
 
-   Add-on Commands
-       hledger  also  searches  for external add-on commands, and will include
+   Add-on commands
+       hledger also searches for external add-on commands,  and  will  include
        these in the commands list.  These are programs or scripts in your PATH
-       whose  name starts with hledger- and ends with a recognised file exten-
+       whose name starts with hledger- and ends with a recognised file  exten-
        sion (currently: no extension, bat,com,exe, hs,lhs,pl,py,rb,rkt,sh).
 
-       Add-ons can be invoked like any hledger command, but there  are  a  few
+       Add-ons  can  be  invoked like any hledger command, but there are a few
        things to be aware of.  Eg if the hledger-web add-on is installed,
 
-       o hledger  -h  web  shows  hledger's  help,  while hledger web -h shows
+       o hledger -h web shows hledger's  help,  while  hledger  web  -h  shows
          hledger-web's help.
 
-       o Flags specific to the add-on must have a preceding --  to  hide  them
-         from  hledger.   So hledger web --serve --port 9000 will be rejected;
+       o Flags  specific  to  the add-on must have a preceding -- to hide them
+         from hledger.  So hledger web --serve --port 9000 will  be  rejected;
          you must use hledger web -- --serve --port 9000.
 
        o You can always run add-ons directly if preferred: hledger-web --serve
          --port 9000.
 
-       Add-ons  are  a relatively easy way to add local features or experiment
-       with new ideas.  They can be  written  in  any  language,  but  haskell
-       scripts  have  a  big  advantage:  they  can  use the same hledger (and
-       haskell) library functions that built-in commands do, for  command-line
+       Add-ons are a relatively easy way to add local features  or  experiment
+       with  new  ideas.   They  can  be  written in any language, but haskell
+       scripts have a big advantage:  they  can  use  the  same  hledger  (and
+       haskell)  library functions that built-in commands do, for command-line
        options, journal parsing, reporting, etc.
 
-       Two  important  add-ons  are the hledger-ui and hledger-web user inter-
+       Two important add-ons are the hledger-ui and  hledger-web  user  inter-
        faces.  These are maintained and released along with hledger:
 
    ui
@@ -3050,23 +3084,23 @@
        hledger-interest generates interest transactions for an account accord-
        ing to various schemes.
 
-       A few more experimental or old add-ons can be found in  hledger's  bin/
+       A  few  more experimental or old add-ons can be found in hledger's bin/
        directory.  These are typically prototypes and not guaranteed to work.
 
 ENVIRONMENT
-       COLUMNS  The  screen  width used by the register command.  Default: the
+       COLUMNS The screen width used by the register  command.   Default:  the
        full terminal width.
 
        LEDGER_FILE The journal file path when not specified with -f.  Default:
-       ~/.hledger.journal  (on  windows,  perhaps C:/Users/USER/.hledger.jour-
+       ~/.hledger.journal (on  windows,  perhaps  C:/Users/USER/.hledger.jour-
        nal).
 
-       A typical value is ~/DIR/YYYY.journal,  where  DIR  is  a  version-con-
-       trolled  finance directory and YYYY is the current year.  Or ~/DIR/cur-
+       A  typical  value  is  ~/DIR/YYYY.journal,  where DIR is a version-con-
+       trolled finance directory and YYYY is the current year.  Or  ~/DIR/cur-
        rent.journal, where current.journal is a symbolic link to YYYY.journal.
 
        On Mac computers, you can set this and other environment variables in a
-       more  thorough  way that also affects applications started from the GUI
+       more thorough way that also affects applications started from  the  GUI
        (say, an Emacs dock icon).  Eg on MacOS Catalina I have a ~/.MacOSX/en-
        vironment.plist file containing
 
@@ -3077,13 +3111,13 @@
        To see the effect you may need to killall Dock, or reboot.
 
 FILES
-       Reads  data from one or more files in hledger journal, timeclock, time-
-       dot,  or  CSV  format  specified   with   -f,   or   $LEDGER_FILE,   or
-       $HOME/.hledger.journal           (on          windows,          perhaps
+       Reads data from one or more files in hledger journal, timeclock,  time-
+       dot,   or   CSV   format   specified   with  -f,  or  $LEDGER_FILE,  or
+       $HOME/.hledger.journal          (on          windows,           perhaps
        C:/Users/USER/.hledger.journal).
 
 LIMITATIONS
-       The need to precede addon command options with  --  when  invoked  from
+       The  need  to  precede  addon command options with -- when invoked from
        hledger is awkward.
 
        When input data contains non-ascii characters, a suitable system locale
@@ -3099,53 +3133,53 @@
        In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger
        add.
 
-       Not all of Ledger's journal file syntax is supported.  See file  format
+       Not  all of Ledger's journal file syntax is supported.  See file format
        differences.
 
-       On  large  data  files,  hledger  is  slower  and uses more memory than
+       On large data files, hledger  is  slower  and  uses  more  memory  than
        Ledger.
 
 TROUBLESHOOTING
-       Here are some issues you might encounter when you run hledger (and  re-
-       member  you  can  also seek help from the IRC channel, mail list or bug
+       Here  are some issues you might encounter when you run hledger (and re-
+       member you can also seek help from the IRC channel, mail  list  or  bug
        tracker):
 
        Successfully installed, but "No command 'hledger' found"
        stack and cabal install binaries into a special directory, which should
-       be  added  to your PATH environment variable.  Eg on unix-like systems,
+       be added to your PATH environment variable.  Eg on  unix-like  systems,
        that is ~/.local/bin and ~/.cabal/bin respectively.
 
        I set a custom LEDGER_FILE, but hledger is still using the default file
-       LEDGER_FILE should be a real environment variable,  not  just  a  shell
-       variable.   The command env | grep LEDGER_FILE should show it.  You may
+       LEDGER_FILE  should  be  a  real environment variable, not just a shell
+       variable.  The command env | grep LEDGER_FILE should show it.  You  may
        need to use export.  Here's an explanation.
 
-       "Illegal byte sequence" or "Invalid or  incomplete  multibyte  or  wide
-       character" errors
-       In order to handle non-ascii letters and symbols (like ), hledger needs
-       an appropriate locale.  This is usually configured system-wide; you can
-       also configure it temporarily.  The locale may need to be one that sup-
-       ports UTF-8, if you built hledger with GHC < 7.2 (or  possibly  always,
-       I'm not sure yet).
+       Getting  errors  like "Illegal byte sequence" or "Invalid or incomplete
+       multibyte or wide character" or "commitAndReleaseBuffer: invalid  argu-
+       ment (invalid character)"
+       Programs compiled with GHC (hledger, haskell build tools, etc.) need to
+       have a UTF-8-aware locale configured in the environment, otherwise they
+       will  fail  with  these  kinds  of errors when they encounter non-ascii
+       characters.
 
-       Here's  an  example  of  setting  the  locale  temporarily,  on  ubuntu
-       gnu/linux:
+       To fix it, set the LANG environment variable to some locale which  sup-
+       ports UTF-8.  The locale you choose must be installed on your system.
 
+       Here's an example of setting LANG temporarily, on Ubuntu GNU/Linux:
+
               $ file my.journal
-              my.journal: UTF-8 Unicode text                 # <- the file is UTF8-encoded
-              $ locale -a
+              my.journal: UTF-8 Unicode text         # the file is UTF8-encoded
+              $ echo $LANG
+              C                                      # LANG is set to the default locale, which does not support UTF8
+              $ locale -a                            # which locales are installed ?
               C
-              en_US.utf8                             # <- a UTF8-aware locale is available
+              en_US.utf8                             # here's a UTF8-aware one we can use
               POSIX
-              $ LANG=en_US.utf8 hledger -f my.journal print   # <- use it for this command
-
-       Here's one way to set it permanently, there are probably better ways:
-
-              $ echo "export LANG=en_US.UTF-8" >>~/.bash_profile
-              $ bash --login
+              $ LANG=en_US.utf8 hledger -f my.journal print   # ensure it is used for this command
 
-       If we preferred to use eg fr_FR.utf8, we might  have  to  install  that
-       first:
+       If  available,  C.UTF-8 will also work.  If your preferred locale isn't
+       listed by locale -a, you might need to install it.   Eg  on  Ubuntu/De-
+       bian:
 
               $ apt-get install language-pack-fr
               $ locale -a
@@ -3159,13 +3193,23 @@
               POSIX
               $ LANG=fr_FR.utf8 hledger -f my.journal print
 
-       Note some platforms allow variant locale spellings, but not all (ubuntu
-       accepts fr_FR.UTF8, mac osx requires exactly fr_FR.UTF-8).
+       Here's how you could set it permanently, if you use a bash shell:
 
+              $ echo "export LANG=en_US.utf8" >>~/.bash_profile
+              $ bash --login
 
+       Exact  spelling  and capitalisation may be important.  Note the differ-
+       ence on MacOS (UTF-8, not utf8).   Some  platforms  (eg  ubuntu)  allow
+       variant spellings, but others (eg macos) require it to be exact:
 
+              $ locale -a | grep -iE en_us.*utf
+              en_US.UTF-8
+              $ LANG=en_US.UTF-8 hledger -f my.journal print
+
+
+
 REPORTING BUGS
-       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel
+       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel
        or hledger mail list)
 
 
@@ -3179,7 +3223,7 @@
 
 
 SEE ALSO
-       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),
+       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),
        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
        dot(5), ledger(1)
 
@@ -3187,4 +3231,4 @@
 
 
 
-hledger 1.17.1.1                  March 2020                        hledger(1)
+hledger 1.18                       June 2020                        hledger(1)
diff --git a/embeddedfiles/hledger_csv.5 b/embeddedfiles/hledger_csv.5
--- a/embeddedfiles/hledger_csv.5
+++ b/embeddedfiles/hledger_csv.5
@@ -1,6 +1,6 @@
 .\"t
 
-.TH "hledger_csv" "5" "March 2020" "hledger 1.17.1" "hledger User Manuals"
+.TH "hledger_csv" "5" "June 2020" "hledger 1.18" "hledger User Manuals"
 
 
 
@@ -19,7 +19,7 @@
 By default this is named like the CSV file with a \f[C].rules\f[R]
 extension added.
 Eg when reading \f[C]FILE.csv\f[R], hledger also looks for
-\f[C]FILE.csv.rules\f[R] in the same directory.
+\f[C]FILE.csv.rules\f[R] in the same directory as \f[C]FILE.csv\f[R].
 You can specify a different rules file with the \f[C]--rules-file\f[R]
 option.
 If a rules file is not found, hledger will create a sample rules file,
@@ -81,6 +81,11 @@
 T}@T{
 inline another CSV rules file
 T}
+T{
+\f[B]\f[CB]balance-type\f[B]\f[R]
+T}@T{
+choose which type of balance assignments to use
+T}
 .TE
 .PP
 Note, for best error messages when reading CSV files, use a
@@ -489,8 +494,8 @@
 .SS Posting field names
 .SS account
 .PP
-\f[C]accountN\f[R], where N is 1 to 9, causes a posting to be generated,
-with that account name.
+\f[C]accountN\f[R], where N is 1 to 99, causes a posting to be
+generated, with that account name.
 .PP
 Most often there are two postings, so you\[aq]ll want to set
 \f[C]account1\f[R] and \f[C]account2\f[R].
@@ -504,14 +509,30 @@
 .SS amount
 .PP
 \f[C]amountN\f[R] sets posting N\[aq]s amount.
-If the CSV uses separate fields for debit and credit amounts, you can
-use \f[C]amountN-in\f[R] and \f[C]amountN-out\f[R] instead.
+If the CSV uses separate fields for inflows and outflows, you can use
+\f[C]amountN-in\f[R] and \f[C]amountN-out\f[R] instead.
+By assigning to \f[C]amount1\f[R], \f[C]amount2\f[R], ...
+etc.
+you can generate anywhere from 0 to 99 postings.
 .PP
-Also, for compatibility with hledger <1.17: \f[C]amount\f[R] or
-\f[C]amount-in\f[R]/\f[C]amount-out\f[R] with no number sets the amount
-for postings 1 and 2.
-For posting 2 the amount is negated, and converted to cost if
-there\[aq]s a transaction price.
+There is also an older, unnumbered form of these names, suitable for
+2-posting transactions, which sets both posting 1\[aq]s and (negated)
+posting 2\[aq]s amount: \f[C]amount\f[R], or \f[C]amount-in\f[R] and
+\f[C]amount-out\f[R].
+This is still supported because it keeps pre-hledger-1.17 csv rules
+files working, and because it can be more succinct, and because it
+converts posting 2\[aq]s amount to cost if there\[aq]s a transaction
+price, which can be useful.
+.PP
+If you have an existing rules file using the unnumbered form, you might
+want to use the numbered form in certain conditional blocks, without
+having to update and retest all the old rules.
+To facilitate this, posting 1 ignores
+\f[C]amount\f[R]/\f[C]amount-in\f[R]/\f[C]amount-out\f[R] if any of
+\f[C]amount1\f[R]/\f[C]amount1-in\f[R]/\f[C]amount1-out\f[R] are
+assigned, and posting 2 ignores them if any of
+\f[C]amount2\f[R]/\f[C]amount2-in\f[R]/\f[C]amount2-out\f[R] are
+assigned, avoiding conflicts.
 .SS currency
 .PP
 If the CSV has the currency symbol in a separate field (ie, not part of
@@ -620,13 +641,19 @@
 .PP
 REGEX is a case-insensitive regular expression which tries to match
 anywhere within the CSV record.
-It is a POSIX extended regular expressions with some additions (see
-Regular expressions in the hledger manual).
-Note: the \[dq]CSV record\[dq] it is matched against is not the original
-record, but a synthetic one, with enclosing double quotes or whitespace
-removed, and always comma-separated.
-(Eg, an SSV record \f[C]2020-01-01; \[dq]Acme, Inc.\[dq]; 1,000\f[R]
-appears to REGEX as \f[C]2020-01-01,Acme, Inc.,1,000\f[R]).
+It is a POSIX ERE (extended regular expression) that also supports GNU
+word boundaries (\f[C]\[rs]b\f[R], \f[C]\[rs]B\f[R], \f[C]\[rs]<\f[R],
+\f[C]\[rs]>\f[R]), and nothing else.
+If you have trouble, be sure to check our
+https://hledger.org/hledger.html#regular-expressions doc.
+.PP
+Important note: the record that is matched is not the original record,
+but a synthetic one, with any enclosing double quotes (but not enclosing
+whitespace) removed, and always comma-separated (which means that a
+field containing a comma will appear like two fields).
+Eg, if the original record is
+\f[C]2020-01-01; \[dq]Acme, Inc.\[dq];  1,000\f[R], the REGEX will
+actually see \f[C]2020-01-01,Acme, Inc.,  1,000\f[R]).
 .PP
 Or, MATCHER can be a field matcher, like this:
 .IP
diff --git a/embeddedfiles/hledger_csv.info b/embeddedfiles/hledger_csv.info
--- a/embeddedfiles/hledger_csv.info
+++ b/embeddedfiles/hledger_csv.info
@@ -3,8 +3,8 @@
 
 File: hledger_csv.info,  Node: Top,  Next: EXAMPLES,  Up: (dir)
 
-hledger_csv(5) hledger 1.17.1
-*****************************
+hledger_csv(5) hledger 1.18
+***************************
 
 CSV - how hledger reads CSV data, and the CSV rules file format
 
@@ -16,9 +16,9 @@
    We describe each CSV file's format with a corresponding _rules file_.
 By default this is named like the CSV file with a '.rules' extension
 added.  Eg when reading 'FILE.csv', hledger also looks for
-'FILE.csv.rules' in the same directory.  You can specify a different
-rules file with the '--rules-file' option.  If a rules file is not
-found, hledger will create a sample rules file, which you'll need to
+'FILE.csv.rules' in the same directory as 'FILE.csv'.  You can specify a
+different rules file with the '--rules-file' option.  If a rules file is
+not found, hledger will create a sample rules file, which you'll need to
 adjust.
 
    This file contains rules describing the CSV data (header line, fields
@@ -38,6 +38,7 @@
 *'date-format'*    describe the format of CSV dates
 *'newest-first'*   disambiguate record order when there's only one date
 *'include'*        inline another CSV rules file
+*'balance-type'*   choose which type of balance assignments to use
 
    Note, for best error messages when reading CSV files, use a '.csv',
 '.tsv' or '.ssv' file extension or file prefix - see File Extension
@@ -465,7 +466,7 @@
 2.2.2.1 account
 ...............
 
-'accountN', where N is 1 to 9, causes a posting to be generated, with
+'accountN', where N is 1 to 99, causes a posting to be generated, with
 that account name.
 
    Most often there are two postings, so you'll want to set 'account1'
@@ -484,14 +485,26 @@
 ..............
 
 'amountN' sets posting N's amount.  If the CSV uses separate fields for
-debit and credit amounts, you can use 'amountN-in' and 'amountN-out'
-instead.
+inflows and outflows, you can use 'amountN-in' and 'amountN-out'
+instead.  By assigning to 'amount1', 'amount2', ...  etc.  you can
+generate anywhere from 0 to 99 postings.
 
-   Also, for compatibility with hledger <1.17: 'amount' or
-'amount-in'/'amount-out' with no number sets the amount for postings 1
-and 2.  For posting 2 the amount is negated, and converted to cost if
-there's a transaction price.
+   There is also an older, unnumbered form of these names, suitable for
+2-posting transactions, which sets both posting 1's and (negated)
+posting 2's amount: 'amount', or 'amount-in' and 'amount-out'.  This is
+still supported because it keeps pre-hledger-1.17 csv rules files
+working, and because it can be more succinct, and because it converts
+posting 2's amount to cost if there's a transaction price, which can be
+useful.
 
+   If you have an existing rules file using the unnumbered form, you
+might want to use the numbered form in certain conditional blocks,
+without having to update and retest all the old rules.  To facilitate
+this, posting 1 ignores 'amount'/'amount-in'/'amount-out' if any of
+'amount1'/'amount1-in'/'amount1-out' are assigned, and posting 2 ignores
+them if any of 'amount2'/'amount2-in'/'amount2-out' are assigned,
+avoiding conflicts.
+
 
 File: hledger_csv.info,  Node: currency,  Next: balance,  Prev: amount,  Up: Posting field names
 
@@ -599,14 +612,18 @@
 REGEX
 
    REGEX is a case-insensitive regular expression which tries to match
-anywhere within the CSV record.  It is a POSIX extended regular
-expressions with some additions (see Regular expressions in the hledger
-manual).  Note: the "CSV record" it is matched against is not the
-original record, but a synthetic one, with enclosing double quotes or
-whitespace removed, and always comma-separated.  (Eg, an SSV record
-'2020-01-01; "Acme, Inc."; 1,000' appears to REGEX as '2020-01-01,Acme,
-Inc.,1,000').
+anywhere within the CSV record.  It is a POSIX ERE (extended regular
+expression) that also supports GNU word boundaries ('\b', '\B', '\<',
+'\>'), and nothing else.  If you have trouble, be sure to check our
+https://hledger.org/hledger.html#regular-expressions doc.
 
+   Important note: the record that is matched is not the original
+record, but a synthetic one, with any enclosing double quotes (but not
+enclosing whitespace) removed, and always comma-separated (which means
+that a field containing a comma will appear like two fields).  Eg, if
+the original record is '2020-01-01; "Acme, Inc."; 1,000', the REGEX will
+actually see '2020-01-01,Acme, Inc., 1,000').
+
    Or, MATCHER can be a field matcher, like this:
 
 %CSVFIELD REGEX
@@ -1019,74 +1036,74 @@
 
 Tag Table:
 Node: Top72
-Node: EXAMPLES2097
-Ref: #examples2203
-Node: Basic2411
-Ref: #basic2511
-Node: Bank of Ireland3053
-Ref: #bank-of-ireland3188
-Node: Amazon4650
-Ref: #amazon4768
-Node: Paypal6487
-Ref: #paypal6581
-Node: CSV RULES14225
-Ref: #csv-rules14334
-Node: skip14610
-Ref: #skip14703
-Node: fields15078
-Ref: #fields15200
-Node: Transaction field names16365
-Ref: #transaction-field-names16525
-Node: Posting field names16636
-Ref: #posting-field-names16788
-Node: account16858
-Ref: #account16974
-Node: amount17510
-Ref: #amount17641
-Node: currency18022
-Ref: #currency18157
-Node: balance18363
-Ref: #balance18497
-Node: comment18814
-Ref: #comment18931
-Node: field assignment19094
-Ref: #field-assignment19237
-Node: separator20055
-Ref: #separator20184
-Node: if20595
-Ref: #if20697
-Node: end22616
-Ref: #end22722
-Node: date-format22946
-Ref: #date-format23078
-Node: newest-first23827
-Ref: #newest-first23965
-Node: include24648
-Ref: #include24777
-Node: balance-type25221
-Ref: #balance-type25341
-Node: TIPS26041
-Ref: #tips26123
-Node: Rapid feedback26379
-Ref: #rapid-feedback26496
-Node: Valid CSV26956
-Ref: #valid-csv27086
-Node: File Extension27278
-Ref: #file-extension27430
-Node: Reading multiple CSV files27840
-Ref: #reading-multiple-csv-files28025
-Node: Valid transactions28266
-Ref: #valid-transactions28444
-Node: Deduplicating importing29072
-Ref: #deduplicating-importing29251
-Node: Setting amounts30284
-Ref: #setting-amounts30453
-Node: Setting currency/commodity31439
-Ref: #setting-currencycommodity31631
-Node: Referencing other fields32434
-Ref: #referencing-other-fields32634
-Node: How CSV rules are evaluated33531
-Ref: #how-csv-rules-are-evaluated33704
+Node: EXAMPLES2174
+Ref: #examples2280
+Node: Basic2488
+Ref: #basic2588
+Node: Bank of Ireland3130
+Ref: #bank-of-ireland3265
+Node: Amazon4727
+Ref: #amazon4845
+Node: Paypal6564
+Ref: #paypal6658
+Node: CSV RULES14302
+Ref: #csv-rules14411
+Node: skip14687
+Ref: #skip14780
+Node: fields15155
+Ref: #fields15277
+Node: Transaction field names16442
+Ref: #transaction-field-names16602
+Node: Posting field names16713
+Ref: #posting-field-names16865
+Node: account16935
+Ref: #account17051
+Node: amount17588
+Ref: #amount17719
+Node: currency18826
+Ref: #currency18961
+Node: balance19167
+Ref: #balance19301
+Node: comment19618
+Ref: #comment19735
+Node: field assignment19898
+Ref: #field-assignment20041
+Node: separator20859
+Ref: #separator20988
+Node: if21399
+Ref: #if21501
+Node: end23657
+Ref: #end23763
+Node: date-format23987
+Ref: #date-format24119
+Node: newest-first24868
+Ref: #newest-first25006
+Node: include25689
+Ref: #include25818
+Node: balance-type26262
+Ref: #balance-type26382
+Node: TIPS27082
+Ref: #tips27164
+Node: Rapid feedback27420
+Ref: #rapid-feedback27537
+Node: Valid CSV27997
+Ref: #valid-csv28127
+Node: File Extension28319
+Ref: #file-extension28471
+Node: Reading multiple CSV files28881
+Ref: #reading-multiple-csv-files29066
+Node: Valid transactions29307
+Ref: #valid-transactions29485
+Node: Deduplicating importing30113
+Ref: #deduplicating-importing30292
+Node: Setting amounts31325
+Ref: #setting-amounts31494
+Node: Setting currency/commodity32480
+Ref: #setting-currencycommodity32672
+Node: Referencing other fields33475
+Ref: #referencing-other-fields33675
+Node: How CSV rules are evaluated34572
+Ref: #how-csv-rules-are-evaluated34745
 
 End Tag Table
 
diff --git a/embeddedfiles/hledger_csv.txt b/embeddedfiles/hledger_csv.txt
--- a/embeddedfiles/hledger_csv.txt
+++ b/embeddedfiles/hledger_csv.txt
@@ -15,9 +15,9 @@
        We describe each CSV file's format with a corresponding rules file.  By
        default  this is named like the CSV file with a .rules extension added.
        Eg when reading FILE.csv, hledger also looks for FILE.csv.rules in  the
-       same  directory.   You  can  specify  a  different  rules file with the
-       --rules-file option.  If a rules file is not found, hledger will create
-       a sample rules file, which you'll need to adjust.
+       same  directory  as  FILE.csv.   You can specify a different rules file
+       with the --rules-file option.  If a rules file is  not  found,  hledger
+       will create a sample rules file, which you'll need to adjust.
 
        This  file  contains rules describing the CSV data (header line, fields
        layout, date format etc.), and how to construct hledger journal entries
@@ -45,20 +45,22 @@
                           when there's only one date
        include            inline  another  CSV rules
                           file
+       balance-type       choose which type of  bal-
+                          ance assignments to use
 
-       Note, for best error messages when reading CSV files, use a .csv,  .tsv
+       Note,  for best error messages when reading CSV files, use a .csv, .tsv
        or .ssv file extension or file prefix - see File Extension below.
 
        There's an introductory Convert CSV files tutorial on hledger.org.
 
 EXAMPLES
-       Here  are  some sample hledger CSV rules files.  See also the full col-
+       Here are some sample hledger CSV rules files.  See also the  full  col-
        lection at:
        https://github.com/simonmichael/hledger/tree/master/examples/csv
 
    Basic
-       At minimum, the rules file must identify the date  and  amount  fields,
-       and  often  it also specifies the date format and how many header lines
+       At  minimum,  the  rules file must identify the date and amount fields,
+       and often it also specifies the date format and how many  header  lines
        there are.  Here's a simple CSV file and a rules file for it:
 
               Date, Description, Id, Amount
@@ -77,8 +79,8 @@
        Default account names are chosen, since we didn't set them.
 
    Bank of Ireland
-       Here's a CSV with two amount fields (Debit and Credit), and  a  balance
-       field,  which we can use to add balance assertions, which is not neces-
+       Here's  a  CSV with two amount fields (Debit and Credit), and a balance
+       field, which we can use to add balance assertions, which is not  neces-
        sary but provides extra error checking:
 
               Date,Details,Debit,Credit,Balance
@@ -120,13 +122,13 @@
                   assets:bank:boi:checking         EUR-5.0 = EUR126.0
                   expenses:unknown                  EUR5.0
 
-       The balance assertions don't raise an error above, because we're  read-
-       ing  directly  from  CSV, but they will be checked if these entries are
+       The  balance assertions don't raise an error above, because we're read-
+       ing directly from CSV, but they will be checked if  these  entries  are
        imported into a journal file.
 
    Amazon
        Here we convert amazon.com order history, and use an if block to gener-
-       ate  a third posting if there's a fee.  (In practice you'd probably get
+       ate a third posting if there's a fee.  (In practice you'd probably  get
        this data from your bank instead, but it's an example.)
 
               "Date","Type","To/From","Name","Status","Amount","Fees","Transaction ID"
@@ -178,7 +180,7 @@
                   expenses:fees           $1.00
 
    Paypal
-       Here's a real-world rules file for (customised) Paypal CSV,  with  some
+       Here's  a  real-world rules file for (customised) Paypal CSV, with some
        Paypal-specific rules, and a second rules file included:
 
               "Date","Time","TimeZone","Name","Type","Status","Currency","Gross","Fee","Net","From Email Address","To Email Address","Transaction ID","Item Title","Item ID","Reference Txn ID","Receipt ID","Balance","Note"
@@ -333,9 +335,9 @@
    skip
               skip N
 
-       The word "skip" followed by a number (or no number,  meaning  1)  tells
-       hledger  to  ignore  this  many non-empty lines preceding the CSV data.
-       (Empty/blank lines are skipped automatically.) You'll need  this  when-
+       The  word  "skip"  followed by a number (or no number, meaning 1) tells
+       hledger to ignore this many non-empty lines  preceding  the  CSV  data.
+       (Empty/blank  lines  are skipped automatically.) You'll need this when-
        ever your CSV data contains header lines.
 
        It also has a second purpose: it can be used inside if blocks to ignore
@@ -344,27 +346,27 @@
    fields
               fields FIELDNAME1, FIELDNAME2, ...
 
-       A fields list (the word  "fields"  followed  by  comma-separated  field
-       names)  is  the quick way to assign CSV field values to hledger fields.
+       A  fields  list  (the  word  "fields" followed by comma-separated field
+       names) is the quick way to assign CSV field values to  hledger  fields.
        It does two things:
 
-       1. it names the CSV fields.  This is optional, but  can  be  convenient
+       1. it  names  the  CSV fields.  This is optional, but can be convenient
           later for interpolating them.
 
        2. when you use a standard hledger field name, it assigns the CSV value
           to that part of the hledger transaction.
 
-       Here's an example that says "use the 1st, 2nd and  4th  fields  as  the
-       transaction's  date,  description  and amount; name the last two fields
+       Here's  an  example  that  says "use the 1st, 2nd and 4th fields as the
+       transaction's date, description and amount; name the  last  two  fields
        for later reference; and ignore the others":
 
               fields date, description, , amount, , , somefield, anotherfield
 
-       Field names may not contain whitespace.  Fields you  don't  care  about
-       can  be  left  unnamed.  Currently there must be least two items (there
+       Field  names  may  not contain whitespace.  Fields you don't care about
+       can be left unnamed.  Currently there must be least  two  items  (there
        must be at least one comma).
 
-       Note, always use comma in the fields list, even if your  CSV  uses  an-
+       Note,  always  use  comma in the fields list, even if your CSV uses an-
        other separator character.
 
        Here are the standard hledger field/pseudo-field names.  For more about
@@ -377,28 +379,39 @@
 
    Posting field names
    account
-       accountN, where N is 1 to 9, causes a posting  to  be  generated,  with
+       accountN,  where  N  is 1 to 99, causes a posting to be generated, with
        that account name.
 
-       Most  often  there are two postings, so you'll want to set account1 and
-       account2.  Typically account1 is associated with the CSV file,  and  is
-       set  once  with  a top-level assignment, while account2 is set based on
+       Most often there are two postings, so you'll want to set  account1  and
+       account2.   Typically  account1 is associated with the CSV file, and is
+       set once with a top-level assignment, while account2 is  set  based  on
        each transaction's description, and in conditional blocks.
 
-       If a posting's account name is left unset but its amount  is  set  (see
-       below),  a default account name will be chosen (like "expenses:unknown"
+       If  a  posting's  account name is left unset but its amount is set (see
+       below), a default account name will be chosen (like  "expenses:unknown"
        or "income:unknown").
 
    amount
-       amountN sets posting N's amount.  If the CSV uses separate  fields  for
-       debit  and  credit  amounts, you can use amountN-in and amountN-out in-
-       stead.
+       amountN  sets  posting N's amount.  If the CSV uses separate fields for
+       inflows and outflows, you can use amountN-in and  amountN-out  instead.
+       By  assigning to amount1, amount2, ...  etc.  you can generate anywhere
+       from 0 to 99 postings.
 
-       Also, for compatibility with hledger <1.17: amount or amount-in/amount-
-       out with no number sets the amount for postings 1 and 2.  For posting 2
-       the amount is negated, and converted to cost if there's  a  transaction
-       price.
+       There is also an older, unnumbered form of these  names,  suitable  for
+       2-posting transactions, which sets both posting 1's and (negated) post-
+       ing 2's amount: amount, or amount-in and  amount-out.   This  is  still
+       supported  because  it  keeps pre-hledger-1.17 csv rules files working,
+       and because it can be more succinct, and because  it  converts  posting
+       2's amount to cost if there's a transaction price, which can be useful.
 
+       If you have an existing rules file using the unnumbered form, you might
+       want to use the numbered form in certain  conditional  blocks,  without
+       having  to  update  and  retest all the old rules.  To facilitate this,
+       posting   1   ignores    amount/amount-in/amount-out    if    any    of
+       amount1/amount1-in/amount1-out are assigned, and posting 2 ignores them
+       if any of amount2/amount2-in/amount2-out are  assigned,  avoiding  con-
+       flicts.
+
    currency
        If the CSV has the currency symbol in a separate field (ie, not part of
        the amount field), you can use currencyN to prepend it to  posting  N's
@@ -474,27 +487,32 @@
               REGEX
 
        REGEX  is  a  case-insensitive  regular expression which tries to match
-       anywhere within the CSV record.  It is a POSIX extended regular expres-
-       sions  with some additions (see Regular expressions in the hledger man-
-       ual).  Note: the "CSV record" it is matched against is not the original
-       record, but a synthetic one, with enclosing double quotes or whitespace
-       removed, and always comma-separated.  (Eg, an  SSV  record  2020-01-01;
-       "Acme, Inc."; 1,000 appears to REGEX as 2020-01-01,Acme, Inc.,1,000).
+       anywhere within the CSV record.  It is a POSIX  ERE  (extended  regular
+       expression)  that  also  supports GNU word boundaries (\b, \B, \<, \>),
+       and  nothing  else.   If  you  have  trouble,  be  sure  to  check  our
+       https://hledger.org/hledger.html#regular-expressions doc.
 
+       Important  note: the record that is matched is not the original record,
+       but a synthetic one, with any enclosing double quotes (but not  enclos-
+       ing whitespace) removed, and always comma-separated (which means that a
+       field containing a comma will appear like  two  fields).   Eg,  if  the
+       original record is 2020-01-01; "Acme, Inc.";  1,000, the REGEX will ac-
+       tually see 2020-01-01,Acme, Inc.,  1,000).
+
        Or, MATCHER can be a field matcher, like this:
 
               %CSVFIELD REGEX
 
-       which  matches just the content of a particular CSV field.  CSVFIELD is
-       a percent sign followed by the field's  name  or  column  number,  like
+       which matches just the content of a particular CSV field.  CSVFIELD  is
+       a  percent  sign  followed  by  the field's name or column number, like
        %date or %1.
 
        A single matcher can be written on the same line as the "if"; or multi-
        ple matchers can be written on the following lines, non-indented.  Mul-
        tiple matchers are OR'd (any one of them can match).
 
-       After  the patterns there should be one or more rules to apply, all in-
-       dented by at least one space.  Three kinds of rule are allowed in  con-
+       After the patterns there should be one or more rules to apply, all  in-
+       dented  by at least one space.  Three kinds of rule are allowed in con-
        ditional blocks:
 
        o field assignments (to set a hledger field)
@@ -518,7 +536,7 @@
                comment  XXX deductible ? check it
 
    end
-       This  rule  can  be  used inside if blocks (only), to make hledger stop
+       This rule can be used inside if blocks (only),  to  make  hledger  stop
        reading this CSV file and move on to the next input file, or to command
        execution.  Eg:
 
@@ -529,10 +547,10 @@
    date-format
               date-format DATEFMT
 
-       This  is  a  helper for the date (and date2) fields.  If your CSV dates
-       are not formatted like YYYY-MM-DD,  YYYY/MM/DD  or  YYYY.MM.DD,  you'll
-       need  to  add  a  date-format rule describing them with a strptime date
-       parsing pattern, which must parse the CSV date value completely.   Some
+       This is a helper for the date (and date2) fields.  If  your  CSV  dates
+       are  not  formatted  like  YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll
+       need to add a date-format rule describing them  with  a  strptime  date
+       parsing  pattern, which must parse the CSV date value completely.  Some
        examples:
 
               # MM/DD/YY
@@ -554,15 +572,15 @@
        mat.html#v:formatTime
 
    newest-first
-       hledger always sorts the generated transactions by date.   Transactions
-       on  the same date should appear in the same order as their CSV records,
-       as hledger can usually auto-detect whether the CSV's  normal  order  is
+       hledger  always sorts the generated transactions by date.  Transactions
+       on the same date should appear in the same order as their CSV  records,
+       as  hledger  can  usually auto-detect whether the CSV's normal order is
        oldest first or newest first.  But if all of the following are true:
 
-       o the  CSV  might  sometimes  contain just one day of data (all records
+       o the CSV might sometimes contain just one day  of  data  (all  records
          having the same date)
 
-       o the CSV records are normally in reverse chronological  order  (newest
+       o the  CSV  records are normally in reverse chronological order (newest
          at the top)
 
        o and you care about preserving the order of same-day transactions
@@ -575,9 +593,9 @@
    include
               include RULESFILE
 
-       This  includes  the  contents  of another CSV rules file at this point.
-       RULESFILE is an absolute file path or a path relative  to  the  current
-       file's  directory.  This can be useful for sharing common rules between
+       This includes the contents of another CSV rules  file  at  this  point.
+       RULESFILE  is  an  absolute file path or a path relative to the current
+       file's directory.  This can be useful for sharing common rules  between
        several rules files, eg:
 
               # someaccount.csv.rules
@@ -592,10 +610,10 @@
 
    balance-type
        Balance assertions generated by assigning to balanceN are of the simple
-       =  type  by  default, which is a single-commodity, subaccount-excluding
+       = type by default, which is  a  single-commodity,  subaccount-excluding
        assertion.  You may find the subaccount-including variants more useful,
-       eg  if  you  have  created some virtual subaccounts of checking to help
-       with budgeting.  You can select a different type of assertion with  the
+       eg if you have created some virtual subaccounts  of  checking  to  help
+       with  budgeting.  You can select a different type of assertion with the
        balance-type rule:
 
               # balance assertions will consider all commodities and all subaccounts
@@ -610,19 +628,19 @@
 
 TIPS
    Rapid feedback
-       It's  a  good idea to get rapid feedback while creating/troubleshooting
+       It's a good idea to get rapid feedback  while  creating/troubleshooting
        CSV rules.  Here's a good way, using entr from http://eradman.com/entr-
        project :
 
               $ ls foo.csv* | entr bash -c 'echo ----; hledger -f foo.csv print desc:SOMEDESC'
 
-       A  desc:  query (eg) is used to select just one, or a few, transactions
-       of interest.  "bash -c" is used to run multiple  commands,  so  we  can
-       echo  a  separator  each  time the command re-runs, making it easier to
+       A desc: query (eg) is used to select just one, or a  few,  transactions
+       of  interest.   "bash  -c"  is used to run multiple commands, so we can
+       echo a separator each time the command re-runs,  making  it  easier  to
        read the output.
 
    Valid CSV
-       hledger accepts CSV conforming to RFC 4180.  When CSV  values  are  en-
+       hledger  accepts  CSV  conforming to RFC 4180.  When CSV values are en-
        closed in quotes, note:
 
        o they must be double quotes (not single quotes)
@@ -630,9 +648,9 @@
        o spaces outside the quotes are not allowed
 
    File Extension
-       CSV  ("Character  Separated  Values") files should be named with one of
-       these filename extensions: .csv, .ssv, .tsv.  Or, the file path  should
-       be  prefixed with one of csv:, ssv:, tsv:.  This helps hledger identify
+       CSV ("Character Separated Values") files should be named  with  one  of
+       these  filename extensions: .csv, .ssv, .tsv.  Or, the file path should
+       be prefixed with one of csv:, ssv:, tsv:.  This helps hledger  identify
        the format and show the right error messages.  For example:
 
               $ hledger -f foo.ssv print
@@ -644,44 +662,44 @@
        More about this: Input files in the hledger manual.
 
    Reading multiple CSV files
-       If you use multiple -f options to read  multiple  CSV  files  at  once,
-       hledger  will  look for a correspondingly-named rules file for each CSV
-       file.  But if you use the --rules-file option, that rules file will  be
+       If  you  use  multiple  -f  options to read multiple CSV files at once,
+       hledger will look for a correspondingly-named rules file for  each  CSV
+       file.   But if you use the --rules-file option, that rules file will be
        used for all the CSV files.
 
    Valid transactions
        After reading a CSV file, hledger post-processes and validates the gen-
        erated journal entries as it would for a journal file - balancing them,
-       applying  balance  assignments,  and canonicalising amount styles.  Any
-       errors at this stage will be reported in the usual way, displaying  the
+       applying balance assignments, and canonicalising  amount  styles.   Any
+       errors  at this stage will be reported in the usual way, displaying the
        problem entry.
 
        There is one exception: balance assertions, if you have generated them,
-       will not be checked, since normally these will work only when  the  CSV
-       data  is part of the main journal.  If you do need to check balance as-
+       will  not  be checked, since normally these will work only when the CSV
+       data is part of the main journal.  If you do need to check balance  as-
        sertions generated from CSV right away, pipe into another hledger:
 
               $ hledger -f file.csv print | hledger -f- print
 
    Deduplicating, importing
-       When you download a CSV file periodically, eg to get your  latest  bank
-       transactions,  the  new  file  may overlap with the old one, containing
+       When  you  download a CSV file periodically, eg to get your latest bank
+       transactions, the new file may overlap with  the  old  one,  containing
        some of the same records.
 
        The import command will (a) detect the new transactions, and (b) append
        just those transactions to your main journal.  It is idempotent, so you
-       don't have to remember how many times you ran it or with which  version
-       of  the  CSV.  (It keeps state in a hidden .latest.FILE.csv file.) This
+       don't  have to remember how many times you ran it or with which version
+       of the CSV.  (It keeps state in a hidden .latest.FILE.csv  file.)  This
        is the easiest way to import CSV data.  Eg:
 
               # download the latest CSV files, then run this command.
               # Note, no -f flags needed here.
               $ hledger import *.csv [--dry]
 
-       This method works for most CSV files.  (Where  records  have  a  stable
+       This  method  works  for  most CSV files.  (Where records have a stable
        chronological order, and new records appear only at the new end.)
 
-       A  number of other tools and workflows, hledger-specific and otherwise,
+       A number of other tools and workflows, hledger-specific and  otherwise,
        exist for converting, deduplicating, classifying and managing CSV data.
        See:
 
@@ -692,43 +710,43 @@
    Setting amounts
        A posting amount can be set in one of these ways:
 
-       o by  assigning  (with  a  fields  list  or field assigment) to amountN
+       o by assigning (with a fields  list  or  field  assigment)  to  amountN
          (posting N's amount) or amount (posting 1's amount)
 
-       o by assigning to amountN-in and amountN-out (or amount-in and  amount-
-         out).   For  each CSV record, whichever of these has a non-zero value
-         will be used, with appropriate sign.   If  both  contain  a  non-zero
+       o by  assigning to amountN-in and amountN-out (or amount-in and amount-
+         out).  For each CSV record, whichever of these has a  non-zero  value
+         will  be  used,  with  appropriate  sign.  If both contain a non-zero
          value, this may not work.
 
-       o by  assigning  to balanceN (or balance) instead of the above, setting
-         the amount indirectly via a balance assignment.  If you do  this  the
+       o by assigning to balanceN (or balance) instead of the  above,  setting
+         the  amount  indirectly via a balance assignment.  If you do this the
          default account name may be wrong, so you should set that explicitly.
 
        There is some special handling for an amount's sign:
 
-       o If  an amount value is parenthesised, it will be de-parenthesised and
+       o If an amount value is parenthesised, it will be de-parenthesised  and
          sign-flipped.
 
-       o If an amount value begins with a double minus sign, those cancel  out
+       o If  an amount value begins with a double minus sign, those cancel out
          and are removed.
 
        o If an amount value begins with a plus sign, that will be removed
 
    Setting currency/commodity
-       If  the  currency/commodity  symbol  is  included  in  the CSV's amount
+       If the currency/commodity  symbol  is  included  in  the  CSV's  amount
        field(s), you don't have to do anything special.
 
        If the currency is provided as a separate CSV field, you can either:
 
-       o assign that to currency, which adds it to all posting  amounts.   The
-         symbol  will prepended to the amount quantity (on the left side).  If
-         you write a trailing space after the symbol, there will  be  a  space
-         between  symbol  and  amount  (an  exception  to the usual whitespace
+       o assign  that  to currency, which adds it to all posting amounts.  The
+         symbol will prepended to the amount quantity (on the left side).   If
+         you  write  a  trailing space after the symbol, there will be a space
+         between symbol and amount  (an  exception  to  the  usual  whitespace
          stripping).
 
        o or assign it to currencyN which adds it to posting N's amount only.
 
-       o or for more control, construct the amount from  symbol  and  quantity
+       o or  for  more  control, construct the amount from symbol and quantity
          using field assignment, eg:
 
                 fields date,description,currency,quantity
@@ -736,9 +754,9 @@
                 amount %quantity %currency
 
    Referencing other fields
-       In  field assignments, you can interpolate only CSV fields, not hledger
-       fields.  In the example below, there's both a CSV field and  a  hledger
-       field  named  amount1, but %amount1 always means the CSV field, not the
+       In field assignments, you can interpolate only CSV fields, not  hledger
+       fields.   In  the example below, there's both a CSV field and a hledger
+       field named amount1, but %amount1 always means the CSV field,  not  the
        hledger field:
 
               # Name the third CSV field "amount1"
@@ -750,7 +768,7 @@
               # Set comment to the CSV amount1 (not the amount1 assigned above)
               comment %amount1
 
-       Here, since there's no CSV amount1 field, %amount1 will produce a  lit-
+       Here,  since there's no CSV amount1 field, %amount1 will produce a lit-
        eral "amount1":
 
               fields date,description,csvamount
@@ -758,7 +776,7 @@
               # Can't interpolate amount1 here
               comment %amount1
 
-       When  there  are  multiple field assignments to the same hledger field,
+       When there are multiple field assignments to the  same  hledger  field,
        only the last one takes effect.  Here, comment's value will be be B, or
        C if "something" is matched, but never A:
 
@@ -768,14 +786,14 @@
                comment C
 
    How CSV rules are evaluated
-       Here's  how  to  think of CSV rules being evaluated (if you really need
+       Here's how to think of CSV rules being evaluated (if  you  really  need
        to).  First,
 
-       o include - all includes are inlined, from top to bottom, depth  first.
-         (At  each  include  point the file is inlined and scanned for further
+       o include  - all includes are inlined, from top to bottom, depth first.
+         (At each include point the file is inlined and  scanned  for  further
          includes, recursively, before proceeding.)
 
-       Then "global" rules are evaluated, top to bottom.  If  a  rule  is  re-
+       Then  "global"  rules  are  evaluated, top to bottom.  If a rule is re-
        peated, the last one wins:
 
        o skip (at top level)
@@ -789,30 +807,30 @@
 
        Then for each CSV record in turn:
 
-       o test all if blocks.  If any of them contain a end rule, skip all  re-
-         maining  CSV  records.  Otherwise if any of them contain a skip rule,
-         skip that many CSV records.   If  there  are  multiple  matched  skip
+       o test  all if blocks.  If any of them contain a end rule, skip all re-
+         maining CSV records.  Otherwise if any of them contain a  skip  rule,
+         skip  that  many  CSV  records.   If  there are multiple matched skip
          rules, the first one wins.
 
-       o collect  all field assignments at top level and in matched if blocks.
-         When there are multiple assignments for a field, keep only  the  last
+       o collect all field assignments at top level and in matched if  blocks.
+         When  there  are multiple assignments for a field, keep only the last
          one.
 
-       o compute  a value for each hledger field - either the one that was as-
+       o compute a value for each hledger field - either the one that was  as-
          signed to it (and interpolate the %CSVFIELDNAME references), or a de-
          fault
 
        o generate a synthetic hledger transaction from these values.
 
-       This  is all part of the CSV reader, one of several readers hledger can
-       use to parse input files.  When all files have been read  successfully,
-       the  transactions  are passed as input to whichever hledger command the
+       This is all part of the CSV reader, one of several readers hledger  can
+       use  to parse input files.  When all files have been read successfully,
+       the transactions are passed as input to whichever hledger  command  the
        user specified.
 
 
 
 REPORTING BUGS
-       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel
+       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel
        or hledger mail list)
 
 
@@ -826,7 +844,7 @@
 
 
 SEE ALSO
-       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),
+       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),
        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
        dot(5), ledger(1)
 
@@ -834,4 +852,4 @@
 
 
 
-hledger 1.17.1                    March 2020                    hledger_csv(5)
+hledger 1.18                       June 2020                    hledger_csv(5)
diff --git a/embeddedfiles/hledger_journal.5 b/embeddedfiles/hledger_journal.5
--- a/embeddedfiles/hledger_journal.5
+++ b/embeddedfiles/hledger_journal.5
@@ -1,6 +1,6 @@
 .\"t
 
-.TH "hledger_journal" "5" "March 2020" "hledger 1.17.1" "hledger User Manuals"
+.TH "hledger_journal" "5" "June 2020" "hledger 1.18" "hledger User Manuals"
 
 
 
@@ -63,7 +63,8 @@
 and any following indented lines beginning with a semicolon)
 .IP \[bu] 2
 0 or more indented \f[I]posting\f[R] lines, describing what was
-transferred and the accounts involved.
+transferred and the accounts involved (indented comment lines are also
+allowed, but not blank lines or non-indented lines).
 .PP
 Here\[aq]s a simple journal file containing one transaction:
 .IP
@@ -409,7 +410,7 @@
 This makes it easy to write account names containing spaces.
 But if you accidentally leave only one space (or tab) before the amount,
 the amount will be considered part of the account name.
-.SS Virtual Postings
+.SS Virtual postings
 .PP
 A posting with a parenthesised account name is called a \f[I]virtual
 posting\f[R] or \f[I]unbalanced posting\f[R], which means it is exempt
@@ -504,9 +505,9 @@
 \f[R]
 .fi
 .PP
-Amounts can be negative.
-The minus sign can be written before or after a left-side commodity
-symbol:
+Amounts can be preceded by a minus sign (or a plus sign, though plus is
+the default), The sign can be written before or after a left-side
+commodity symbol:
 .IP
 .nf
 \f[C]
@@ -515,6 +516,16 @@
 \f[R]
 .fi
 .PP
+One or more spaces between the sign and the number are acceptable when
+parsing (but they won\[aq]t be displayed in output):
+.IP
+.nf
+\f[C]
++ $1
+$-      1
+\f[R]
+.fi
+.PP
 Scientific E notation is allowed:
 .IP
 .nf
@@ -586,7 +597,7 @@
 Otherwise the format of the first posting amount in that commodity seen
 in the journal is used.
 But the number of decimal places (\[dq]precision\[dq]) will be the
-maximum from all posting amounts in that commmodity.
+maximum from all posting amounts in that commodity.
 .IP \[bu] 2
 Or if there are no such amounts in the journal, a default format is used
 (like \f[C]$1000.00\f[R]).
@@ -601,6 +612,12 @@
 journal, with the max observed number of decimal places.
 If you want to see fewer decimal places in reports, use a commodity
 directive to override that.
+.PP
+hledger uses banker\[aq]s rounding: it rounds to the nearest even
+number, eg 0.5 displayed with zero decimal places is \[dq]0\[dq]).
+(Note, prior to hledger 1.17.1 this could vary if hledger happened to be
+built with an old version of Decimal (<0.5.1); since 1.17.1 it\[aq]s
+guaranteed.)
 .SS Transaction prices
 .PP
 Within a transaction, you can note an amount\[aq]s price in another
@@ -653,9 +670,10 @@
 \f[R]
 .fi
 .RE
-.PP
-(Ledger users: Ledger uses a different syntax for fixed prices,
-\f[C]{=UNITPRICE}\f[R], which hledger currently ignores).
+.IP "5." 3
+Like 1 and 2, but the \f[C]\[at]\f[R] or \f[C]\[at]\[at]\f[R] is
+parenthesised; this is for compatibility with Ledger journals (Virtual
+posting costs), and in hledger is equivalent to 1 and 2.
 .PP
 Use the \f[C]-B/--cost\f[R] flag to convert amounts to their transaction
 price\[aq]s commodity, if any.
@@ -694,8 +712,19 @@
                 \[Eu]100  assets:euros
 \f[R]
 .fi
-.SS Balance Assertions
+.SS Lot prices and lot dates
 .PP
+Ledger allows another kind of price, lot price (four variants:
+\f[C]{UNITPRICE}\f[R], \f[C]{{TOTALPRICE}}\f[R],
+\f[C]{=FIXEDUNITPRICE}\f[R], \f[C]{{=FIXEDTOTALPRICE}}\f[R]), and/or a
+lot date (\f[C][DATE]\f[R]) to be specified.
+These are normally used to select a lot when selling investments.
+hledger will parse these, for compatibility with Ledger journals, but
+currently ignores them.
+A transaction price, lot price and/or lot date may appear in any order,
+after the posting amount and before the balance assertion if any.
+.SS Balance assertions
+.PP
 hledger supports Ledger-style balance assertions in journal files.
 These look like, for example, \f[C]= EXPECTEDBALANCE\f[R] following a
 posting\[aq]s amount.
@@ -850,7 +879,7 @@
 Eg a commodity directive may limit the display precision, but this will
 not affect balance assertions.
 Balance assertion failure messages show exact amounts.
-.SS Balance Assignments
+.SS Balance assignments
 .PP
 Ledger-style balance assignments are also supported.
 These are like balance assertions, but with no posting amount on the
@@ -1104,17 +1133,25 @@
 .IP
 .nf
 \f[C]
-include path/to/file.journal
+include FILEPATH
 \f[R]
 .fi
 .PP
-If the path does not begin with a slash, it is relative to the current
-file.
-The include file path may contain common glob patterns (e.g.
-\f[C]*\f[R]).
+Only journal files can include, and only journal, timeclock or timedot
+files can be included (not CSV files, currently).
 .PP
-The \f[C]include\f[R] directive can only be used in journal files.
-It can include journal, timeclock or timedot files, but not CSV files.
+If the file path does not begin with a slash, it is relative to the
+current file\[aq]s folder.
+.PP
+It may contain glob patterns to match multiple files, eg:
+\f[C]include *.journal\f[R].
+.PP
+Or a tilde, meaning home directory:
+\f[C]include \[ti]/main.journal\f[R].
+.PP
+It may also be prefixed to force a specific file format, overriding the
+file extension (as described in hledger.1 -> Input files):
+\f[C]include timedot:\[ti]/notes/2020*.md\f[R].
 .SS Default year
 .PP
 You can set a default year to be used for subsequent dates which
@@ -1197,6 +1234,10 @@
 significant.
 The number must include a decimal mark: either a period or a comma,
 followed by 0 or more decimal digits.
+.PP
+Note hledger normally uses banker\[aq]s rounding, so 0.5 displayed with
+zero decimal digits is \[dq]0\[dq].
+(More at Amount display style.)
 .SS Default commodity
 .PP
 The \f[C]D\f[R] directive sets a default commodity, to be used for
@@ -1227,7 +1268,7 @@
   b
 \f[R]
 .fi
-.SS Market prices
+.SS Declaring market prices
 .PP
 The \f[C]P\f[R] directive declares a market price, which is an exchange
 rate between two commodities on a certain date.
@@ -1260,8 +1301,9 @@
 \f[R]
 .fi
 .PP
-The \f[C]-V/--value\f[R] flag can be used to convert reported amounts to
-another commodity using these prices.
+The \f[C]-V\f[R], \f[C]-X\f[R] and \f[C]--value\f[R] flags use these
+market prices to show amount values in another commodity.
+See Valuation.
 .SS Declaring accounts
 .PP
 \f[C]account\f[R] directives can be used to pre-declare accounts.
@@ -1755,25 +1797,25 @@
 expression.
 .SS Forecasting with periodic transactions
 .PP
-With the \f[C]--forecast\f[R] flag, each periodic transaction rule
-generates future transactions recurring at the specified interval.
-These are not saved in the journal, but appear in all reports.
-They will look like normal transactions, but with an extra tag:
-.IP \[bu] 2
-\f[C]generated-transaction:\[ti] PERIODICEXPR\f[R] - shows that this was
-generated by a periodic transaction rule, and the period
-.PP
-There is also a hidden tag, with an underscore prefix, which does not
-appear in hledger\[aq]s output:
-.IP \[bu] 2
-\f[C]_generated-transaction:\[ti] PERIODICEXPR\f[R]
+The \f[C]--forecast\f[R] flag activates any periodic transaction rules
+in the journal.
+They will generate temporary recurring transactions, which are not saved
+in the journal, but will appear in all reports (eg print).
+This can be useful for estimating balances into the future, or
+experimenting with different scenarios.
+Or, it can be used as a data entry aid: describe recurring transactions,
+and every so often copy the output of \f[C]print --forecast\f[R] into
+the journal.
 .PP
-This can be used to match transactions generated \[dq]just now\[dq],
-rather than generated in the past and saved to the journal.
+These transactions will have an extra tag indicating which periodic rule
+generated them: \f[C]generated-transaction:\[ti] PERIODICEXPR\f[R].
+And a similar, hidden tag (beginning with an underscore) which, because
+it\[aq]s never displayed by print, can be used to match transactions
+generated \[dq]just now\[dq]:
+\f[C]_generated-transaction:\[ti] PERIODICEXPR\f[R].
 .PP
-Forecast transactions start on the first occurrence, and end on the last
-occurrence, of their interval within the forecast period.
-The forecast period:
+Periodic transactions are generated within some forecast period.
+By default, this
 .IP \[bu] 2
 begins on the later of
 .RS 2
@@ -1784,27 +1826,26 @@
 journal, or today if there are no normal transactions.
 .RE
 .IP \[bu] 2
-ends on the report end date if specified with -e/-p/date:, or 180 days
-from today.
-.PP
-where \[dq]today\[dq] means the current date at report time.
-The \[dq]later of\[dq] rule ensures that forecast transactions do not
-overlap normal transactions in time; they will begin only after normal
-transactions end.
-.PP
-Forecasting can be useful for estimating balances into the future, and
-experimenting with different scenarios.
-Note the start date logic means that forecasted transactions are
-automatically replaced by normal transactions as you add those.
+ends on the report end date if specified with -e/-p/date:, or 6 months
+(180 days) from today.
 .PP
-Forecasting can also help with data entry: describe most of your
-transactions with periodic rules, and every so often copy the output of
-\f[C]print --forecast\f[R] to the journal.
+This means that periodic transactions will begin only after the latest
+recorded transaction.
+And a recorded transaction dated in the future can prevent generation of
+periodic transactions.
+(You can avoid that by writing the future transaction as a one-time
+periodic rule instead - put tilde before the date, eg
+\f[C]\[ti] YYYY-MM-DD ...\f[R]).
 .PP
-You can generate one-time transactions too: just write a period
-expression specifying a date with no report interval.
-(You could also write a normal transaction with a future date, but
-remember this disables forecast transactions on previous dates.)
+Or, you can set your own arbitrary \[dq]forecast period\[dq], which can
+overlap recorded transactions, and need not be in the future, by
+providing an option argument, like \f[C]--forecast=PERIODEXPR\f[R].
+Note the equals sign is required, a space won\[aq]t work.
+PERIODEXPR is a period expression, which can specify the start date, end
+date, or both, like in a \f[C]date:\f[R] query.
+(See also hledger.1 -> Report start & end date).
+Some examples: \f[C]--forecast=202001-202004\f[R],
+\f[C]--forecast=jan-\f[R], \f[C]--forecast=2020\f[R].
 .SS Budgeting with periodic transactions
 .PP
 With the \f[C]--budget\f[R] flag, currently supported by the balance
diff --git a/embeddedfiles/hledger_journal.info b/embeddedfiles/hledger_journal.info
--- a/embeddedfiles/hledger_journal.info
+++ b/embeddedfiles/hledger_journal.info
@@ -4,8 +4,8 @@
 
 File: hledger_journal.info,  Node: Top,  Up: (dir)
 
-hledger_journal(5) hledger 1.17.1
-*********************************
+hledger_journal(5) hledger 1.18
+*******************************
 
 Journal - hledger's default file format, representing a General Journal
 
@@ -62,7 +62,8 @@
    * a comment (any remaining text following a semicolon until end of
      line, and any following indented lines beginning with a semicolon)
    * 0 or more indented _posting_ lines, describing what was transferred
-     and the accounts involved.
+     and the accounts involved (indented comment lines are also allowed,
+     but not blank lines or non-indented lines).
 
    Here's a simple journal file containing one transaction:
 
@@ -81,8 +82,9 @@
 * Account names::
 * Amounts::
 * Transaction prices::
-* Balance Assertions::
-* Balance Assignments::
+* Lot prices and lot dates::
+* Balance assertions::
+* Balance assignments::
 * Directives::
 * Periodic transactions::
 * Auto postings::
@@ -377,12 +379,12 @@
 
 * Menu:
 
-* Virtual Postings::
+* Virtual postings::
 
 
-File: hledger_journal.info,  Node: Virtual Postings,  Up: Postings
+File: hledger_journal.info,  Node: Virtual postings,  Up: Postings
 
-1.6.1 Virtual Postings
+1.6.1 Virtual postings
 ----------------------
 
 A posting with a parenthesised account name is called a _virtual
@@ -459,12 +461,19 @@
 
 3 "no. 42 green apples"
 
-   Amounts can be negative.  The minus sign can be written before or
-after a left-side commodity symbol:
+   Amounts can be preceded by a minus sign (or a plus sign, though plus
+is the default), The sign can be written before or after a left-side
+commodity symbol:
 
 -$1
 $-1
 
+   One or more spaces between the sign and the number are acceptable
+when parsing (but they won't be displayed in output):
+
++ $1
+$-      1
+
    Scientific E notation is allowed:
 
 1E-6
@@ -529,7 +538,7 @@
    * Otherwise the format of the first posting amount in that commodity
      seen in the journal is used.  But the number of decimal places
      ("precision") will be the maximum from all posting amounts in that
-     commmodity.
+     commodity.
 
    * Or if there are no such amounts in the journal, a default format is
      used (like '$1000.00').
@@ -544,8 +553,13 @@
 see fewer decimal places in reports, use a commodity directive to
 override that.
 
+   hledger uses banker's rounding: it rounds to the nearest even number,
+eg 0.5 displayed with zero decimal places is "0").  (Note, prior to
+hledger 1.17.1 this could vary if hledger happened to be built with an
+old version of Decimal (<0.5.1); since 1.17.1 it's guaranteed.)
+
 
-File: hledger_journal.info,  Node: Transaction prices,  Next: Balance Assertions,  Prev: Amounts,  Up: Transactions
+File: hledger_journal.info,  Node: Transaction prices,  Next: Lot prices and lot dates,  Prev: Amounts,  Up: Transactions
 
 1.9 Transaction prices
 ======================
@@ -579,8 +593,9 @@
        assets:euros     €100          ; one hundred euros purchased
        assets:dollars  $-135          ; for $135
 
-   (Ledger users: Ledger uses a different syntax for fixed prices,
-'{=UNITPRICE}', which hledger currently ignores).
+  4. 5. Like 1 and 2, but the '@' or '@@' is parenthesised; this is for
+     compatibility with Ledger journals (Virtual posting costs), and in
+     hledger is equivalent to 1 and 2.
 
    Use the '-B/--cost' flag to convert amounts to their transaction
 price's commodity, if any.  (mnemonic: "B" is from "cost Basis", as in
@@ -608,9 +623,24 @@
                 €100  assets:euros
 
 
-File: hledger_journal.info,  Node: Balance Assertions,  Next: Balance Assignments,  Prev: Transaction prices,  Up: Transactions
+File: hledger_journal.info,  Node: Lot prices and lot dates,  Next: Balance assertions,  Prev: Transaction prices,  Up: Transactions
 
-1.10 Balance Assertions
+1.10 Lot prices and lot dates
+=============================
+
+Ledger allows another kind of price, lot price (four variants:
+'{UNITPRICE}', '{{TOTALPRICE}}', '{=FIXEDUNITPRICE}',
+'{{=FIXEDTOTALPRICE}}'), and/or a lot date ('[DATE]') to be specified.
+These are normally used to select a lot when selling investments.
+hledger will parse these, for compatibility with Ledger journals, but
+currently ignores them.  A transaction price, lot price and/or lot date
+may appear in any order, after the posting amount and before the balance
+assertion if any.
+
+
+File: hledger_journal.info,  Node: Balance assertions,  Next: Balance assignments,  Prev: Lot prices and lot dates,  Up: Transactions
+
+1.11 Balance assertions
 =======================
 
 hledger supports Ledger-style balance assertions in journal files.
@@ -646,9 +676,9 @@
 * Assertions and precision::
 
 
-File: hledger_journal.info,  Node: Assertions and ordering,  Next: Assertions and included files,  Up: Balance Assertions
+File: hledger_journal.info,  Node: Assertions and ordering,  Next: Assertions and included files,  Up: Balance assertions
 
-1.10.1 Assertions and ordering
+1.11.1 Assertions and ordering
 ------------------------------
 
 hledger sorts an account's postings and assertions first by date and
@@ -665,9 +695,9 @@
 can assert intra-day balances.
 
 
-File: hledger_journal.info,  Node: Assertions and included files,  Next: Assertions and multiple -f options,  Prev: Assertions and ordering,  Up: Balance Assertions
+File: hledger_journal.info,  Node: Assertions and included files,  Next: Assertions and multiple -f options,  Prev: Assertions and ordering,  Up: Balance assertions
 
-1.10.2 Assertions and included files
+1.11.2 Assertions and included files
 ------------------------------------
 
 With included files, things are a little more complicated.  Including
@@ -677,18 +707,18 @@
 you'll have to put the assertion in the right file.
 
 
-File: hledger_journal.info,  Node: Assertions and multiple -f options,  Next: Assertions and commodities,  Prev: Assertions and included files,  Up: Balance Assertions
+File: hledger_journal.info,  Node: Assertions and multiple -f options,  Next: Assertions and commodities,  Prev: Assertions and included files,  Up: Balance assertions
 
-1.10.3 Assertions and multiple -f options
+1.11.3 Assertions and multiple -f options
 -----------------------------------------
 
 Balance assertions don't work well across files specified with multiple
 -f options.  Use include or concatenate the files instead.
 
 
-File: hledger_journal.info,  Node: Assertions and commodities,  Next: Assertions and prices,  Prev: Assertions and multiple -f options,  Up: Balance Assertions
+File: hledger_journal.info,  Node: Assertions and commodities,  Next: Assertions and prices,  Prev: Assertions and multiple -f options,  Up: Balance assertions
 
-1.10.4 Assertions and commodities
+1.11.4 Assertions and commodities
 ---------------------------------
 
 The asserted balance must be a simple single-commodity amount, and in
@@ -734,9 +764,9 @@
   a:euro   0 ==  1€
 
 
-File: hledger_journal.info,  Node: Assertions and prices,  Next: Assertions and subaccounts,  Prev: Assertions and commodities,  Up: Balance Assertions
+File: hledger_journal.info,  Node: Assertions and prices,  Next: Assertions and subaccounts,  Prev: Assertions and commodities,  Up: Balance assertions
 
-1.10.5 Assertions and prices
+1.11.5 Assertions and prices
 ----------------------------
 
 Balance assertions ignore transaction prices, and should normally be
@@ -752,9 +782,9 @@
 _assignments_ do use them (see below).
 
 
-File: hledger_journal.info,  Node: Assertions and subaccounts,  Next: Assertions and virtual postings,  Prev: Assertions and prices,  Up: Balance Assertions
+File: hledger_journal.info,  Node: Assertions and subaccounts,  Next: Assertions and virtual postings,  Prev: Assertions and prices,  Up: Balance assertions
 
-1.10.6 Assertions and subaccounts
+1.11.6 Assertions and subaccounts
 ---------------------------------
 
 The balance assertions above ('=' and '==') do not count the balance
@@ -769,9 +799,9 @@
   checking         1  ==* 11
 
 
-File: hledger_journal.info,  Node: Assertions and virtual postings,  Next: Assertions and precision,  Prev: Assertions and subaccounts,  Up: Balance Assertions
+File: hledger_journal.info,  Node: Assertions and virtual postings,  Next: Assertions and precision,  Prev: Assertions and subaccounts,  Up: Balance assertions
 
-1.10.7 Assertions and virtual postings
+1.11.7 Assertions and virtual postings
 --------------------------------------
 
 Balance assertions are checked against all postings, both real and
@@ -779,9 +809,9 @@
 query.
 
 
-File: hledger_journal.info,  Node: Assertions and precision,  Prev: Assertions and virtual postings,  Up: Balance Assertions
+File: hledger_journal.info,  Node: Assertions and precision,  Prev: Assertions and virtual postings,  Up: Balance assertions
 
-1.10.8 Assertions and precision
+1.11.8 Assertions and precision
 -------------------------------
 
 Balance assertions compare the exactly calculated amounts, which are not
@@ -790,9 +820,9 @@
 assertion failure messages show exact amounts.
 
 
-File: hledger_journal.info,  Node: Balance Assignments,  Next: Directives,  Prev: Balance Assertions,  Up: Transactions
+File: hledger_journal.info,  Node: Balance assignments,  Next: Directives,  Prev: Balance assertions,  Up: Transactions
 
-1.11 Balance Assignments
+1.12 Balance assignments
 ========================
 
 Ledger-style balance assignments are also supported.  These are like
@@ -827,9 +857,9 @@
 * Balance assignments and prices::
 
 
-File: hledger_journal.info,  Node: Balance assignments and prices,  Up: Balance Assignments
+File: hledger_journal.info,  Node: Balance assignments and prices,  Up: Balance assignments
 
-1.11.1 Balance assignments and prices
+1.12.1 Balance assignments and prices
 -------------------------------------
 
 A transaction price in a balance assignment will cause the calculated
@@ -843,9 +873,9 @@
     (a)         $1 @ €2 = $1 @ €2
 
 
-File: hledger_journal.info,  Node: Directives,  Next: Periodic transactions,  Prev: Balance Assignments,  Up: Transactions
+File: hledger_journal.info,  Node: Directives,  Next: Periodic transactions,  Prev: Balance assignments,  Up: Transactions
 
-1.12 Directives
+1.13 Directives
 ===============
 
 A directive is a line in the journal beginning with a special keyword,
@@ -941,7 +971,7 @@
 * Default year::
 * Declaring commodities::
 * Default commodity::
-* Market prices::
+* Declaring market prices::
 * Declaring accounts::
 * Rewriting accounts::
 * Default parent account::
@@ -949,7 +979,7 @@
 
 File: hledger_journal.info,  Node: Directives and multiple files,  Next: Comment blocks,  Up: Directives
 
-1.12.1 Directives and multiple files
+1.13.1 Directives and multiple files
 ------------------------------------
 
 If you use multiple '-f'/'--file' options, or the 'include' directive,
@@ -969,7 +999,7 @@
 
 File: hledger_journal.info,  Node: Comment blocks,  Next: Including other files,  Prev: Directives and multiple files,  Up: Directives
 
-1.12.2 Comment blocks
+1.13.2 Comment blocks
 ---------------------
 
 A line containing just 'comment' starts a commented region of the file,
@@ -979,25 +1009,33 @@
 
 File: hledger_journal.info,  Node: Including other files,  Next: Default year,  Prev: Comment blocks,  Up: Directives
 
-1.12.3 Including other files
+1.13.3 Including other files
 ----------------------------
 
 You can pull in the content of additional files by writing an include
 directive, like this:
 
-include path/to/file.journal
+include FILEPATH
 
-   If the path does not begin with a slash, it is relative to the
-current file.  The include file path may contain common glob patterns
-(e.g.  '*').
+   Only journal files can include, and only journal, timeclock or
+timedot files can be included (not CSV files, currently).
 
-   The 'include' directive can only be used in journal files.  It can
-include journal, timeclock or timedot files, but not CSV files.
+   If the file path does not begin with a slash, it is relative to the
+current file's folder.
 
+   It may contain glob patterns to match multiple files, eg: 'include
+*.journal'.
+
+   Or a tilde, meaning home directory: 'include ~/main.journal'.
+
+   It may also be prefixed to force a specific file format, overriding
+the file extension (as described in hledger.1 -> Input files): 'include
+timedot:~/notes/2020*.md'.
+
 
 File: hledger_journal.info,  Node: Default year,  Next: Declaring commodities,  Prev: Including other files,  Up: Directives
 
-1.12.4 Default year
+1.13.4 Default year
 -------------------
 
 You can set a default year to be used for subsequent dates which don't
@@ -1023,7 +1061,7 @@
 
 File: hledger_journal.info,  Node: Declaring commodities,  Next: Default commodity,  Prev: Default year,  Up: Directives
 
-1.12.5 Declaring commodities
+1.13.5 Declaring commodities
 ----------------------------
 
 The 'commodity' directive has several functions:
@@ -1070,10 +1108,13 @@
 significant.  The number must include a decimal mark: either a period or
 a comma, followed by 0 or more decimal digits.
 
+   Note hledger normally uses banker's rounding, so 0.5 displayed with
+zero decimal digits is "0".  (More at Amount display style.)
+
 
-File: hledger_journal.info,  Node: Default commodity,  Next: Market prices,  Prev: Declaring commodities,  Up: Directives
+File: hledger_journal.info,  Node: Default commodity,  Next: Declaring market prices,  Prev: Declaring commodities,  Up: Directives
 
-1.12.6 Default commodity
+1.13.6 Default commodity
 ------------------------
 
 The 'D' directive sets a default commodity, to be used for amounts
@@ -1098,10 +1139,10 @@
   b
 
 
-File: hledger_journal.info,  Node: Market prices,  Next: Declaring accounts,  Prev: Default commodity,  Up: Directives
+File: hledger_journal.info,  Node: Declaring market prices,  Next: Declaring accounts,  Prev: Default commodity,  Up: Directives
 
-1.12.7 Market prices
---------------------
+1.13.7 Declaring market prices
+------------------------------
 
 The 'P' directive declares a market price, which is an exchange rate
 between two commodities on a certain date.  (In Ledger, they are called
@@ -1124,13 +1165,13 @@
 P 2009/1/1 € $1.35
 P 2010/1/1 € $1.40
 
-   The '-V/--value' flag can be used to convert reported amounts to
-another commodity using these prices.
+   The '-V', '-X' and '--value' flags use these market prices to show
+amount values in another commodity.  See Valuation.
 
 
-File: hledger_journal.info,  Node: Declaring accounts,  Next: Rewriting accounts,  Prev: Market prices,  Up: Directives
+File: hledger_journal.info,  Node: Declaring accounts,  Next: Rewriting accounts,  Prev: Declaring market prices,  Up: Directives
 
-1.12.8 Declaring accounts
+1.13.8 Declaring accounts
 -------------------------
 
 'account' directives can be used to pre-declare accounts.  Though not
@@ -1163,7 +1204,7 @@
 
 File: hledger_journal.info,  Node: Account comments,  Next: Account subdirectives,  Up: Declaring accounts
 
-1.12.8.1 Account comments
+1.13.8.1 Account comments
 .........................
 
 Comments, beginning with a semicolon, can be added:
@@ -1183,7 +1224,7 @@
 
 File: hledger_journal.info,  Node: Account subdirectives,  Next: Account types,  Prev: Account comments,  Up: Declaring accounts
 
-1.12.8.2 Account subdirectives
+1.13.8.2 Account subdirectives
 ..............................
 
 We also allow (and ignore) Ledger-style indented subdirectives, just for
@@ -1201,7 +1242,7 @@
 
 File: hledger_journal.info,  Node: Account types,  Next: Account display order,  Prev: Account subdirectives,  Up: Declaring accounts
 
-1.12.8.3 Account types
+1.13.8.3 Account types
 ......................
 
 hledger recognises five types (or classes) of account: Asset, Liability,
@@ -1246,7 +1287,7 @@
 
 File: hledger_journal.info,  Node: Account display order,  Prev: Account types,  Up: Declaring accounts
 
-1.12.8.4 Account display order
+1.13.8.4 Account display order
 ..............................
 
 Account directives also set the order in which accounts are displayed,
@@ -1292,7 +1333,7 @@
 
 File: hledger_journal.info,  Node: Rewriting accounts,  Next: Default parent account,  Prev: Declaring accounts,  Up: Directives
 
-1.12.9 Rewriting accounts
+1.13.9 Rewriting accounts
 -------------------------
 
 You can define account alias rules which rewrite your account names, or
@@ -1322,7 +1363,7 @@
 
 File: hledger_journal.info,  Node: Basic aliases,  Next: Regex aliases,  Up: Rewriting accounts
 
-1.12.9.1 Basic aliases
+1.13.9.1 Basic aliases
 ......................
 
 To set an account alias, use the 'alias' directive in your journal file.
@@ -1345,7 +1386,7 @@
 
 File: hledger_journal.info,  Node: Regex aliases,  Next: Combining aliases,  Prev: Basic aliases,  Up: Rewriting accounts
 
-1.12.9.2 Regex aliases
+1.13.9.2 Regex aliases
 ......................
 
 There is also a more powerful variant that uses a regular expression,
@@ -1370,7 +1411,7 @@
 
 File: hledger_journal.info,  Node: Combining aliases,  Next: Aliases and multiple files,  Prev: Regex aliases,  Up: Rewriting accounts
 
-1.12.9.3 Combining aliases
+1.13.9.3 Combining aliases
 ..........................
 
 You can define as many aliases as you like, using journal directives
@@ -1407,7 +1448,7 @@
 
 File: hledger_journal.info,  Node: Aliases and multiple files,  Next: end aliases,  Prev: Combining aliases,  Up: Rewriting accounts
 
-1.12.9.4 Aliases and multiple files
+1.13.9.4 Aliases and multiple files
 ...................................
 
 As explained at Directives and multiple files, 'alias' directives do not
@@ -1439,7 +1480,7 @@
 
 File: hledger_journal.info,  Node: end aliases,  Prev: Aliases and multiple files,  Up: Rewriting accounts
 
-1.12.9.5 'end aliases'
+1.13.9.5 'end aliases'
 ......................
 
 You can clear (forget) all currently defined aliases with the 'end
@@ -1450,7 +1491,7 @@
 
 File: hledger_journal.info,  Node: Default parent account,  Prev: Rewriting accounts,  Up: Directives
 
-1.12.10 Default parent account
+1.13.10 Default parent account
 ------------------------------
 
 You can specify a parent account which will be prepended to all accounts
@@ -1491,7 +1532,7 @@
 
 File: hledger_journal.info,  Node: Periodic transactions,  Next: Auto postings,  Prev: Directives,  Up: Transactions
 
-1.13 Periodic transactions
+1.14 Periodic transactions
 ==========================
 
 Periodic transaction rules describe transactions that recur.  They allow
@@ -1536,7 +1577,7 @@
 
 File: hledger_journal.info,  Node: Periodic rule syntax,  Next: Two spaces between period expression and description!,  Up: Periodic transactions
 
-1.13.1 Periodic rule syntax
+1.14.1 Periodic rule syntax
 ---------------------------
 
 A periodic transaction rule looks like a normal journal entry, with the
@@ -1559,7 +1600,7 @@
 
 File: hledger_journal.info,  Node: Two spaces between period expression and description!,  Next: Forecasting with periodic transactions,  Prev: Periodic rule syntax,  Up: Periodic transactions
 
-1.13.2 Two spaces between period expression and description!
+1.14.2 Two spaces between period expression and description!
 ------------------------------------------------------------
 
 If the period expression is followed by a transaction description, these
@@ -1584,60 +1625,53 @@
 
 File: hledger_journal.info,  Node: Forecasting with periodic transactions,  Next: Budgeting with periodic transactions,  Prev: Two spaces between period expression and description!,  Up: Periodic transactions
 
-1.13.3 Forecasting with periodic transactions
+1.14.3 Forecasting with periodic transactions
 ---------------------------------------------
 
-With the '--forecast' flag, each periodic transaction rule generates
-future transactions recurring at the specified interval.  These are not
-saved in the journal, but appear in all reports.  They will look like
-normal transactions, but with an extra tag:
-
-   * 'generated-transaction:~ PERIODICEXPR' - shows that this was
-     generated by a periodic transaction rule, and the period
-
-   There is also a hidden tag, with an underscore prefix, which does not
-appear in hledger's output:
-
-   * '_generated-transaction:~ PERIODICEXPR'
+The '--forecast' flag activates any periodic transaction rules in the
+journal.  They will generate temporary recurring transactions, which are
+not saved in the journal, but will appear in all reports (eg print).
+This can be useful for estimating balances into the future, or
+experimenting with different scenarios.  Or, it can be used as a data
+entry aid: describe recurring transactions, and every so often copy the
+output of 'print --forecast' into the journal.
 
-   This can be used to match transactions generated "just now", rather
-than generated in the past and saved to the journal.
+   These transactions will have an extra tag indicating which periodic
+rule generated them: 'generated-transaction:~ PERIODICEXPR'.  And a
+similar, hidden tag (beginning with an underscore) which, because it's
+never displayed by print, can be used to match transactions generated
+"just now": '_generated-transaction:~ PERIODICEXPR'.
 
-   Forecast transactions start on the first occurrence, and end on the
-last occurrence, of their interval within the forecast period.  The
-forecast period:
+   Periodic transactions are generated within some forecast period.  By
+default, this
 
    * begins on the later of
         * the report start date if specified with -b/-p/date:
         * the day after the latest normal (non-periodic) transaction in
           the journal, or today if there are no normal transactions.
 
-   * ends on the report end date if specified with -e/-p/date:, or 180
-     days from today.
-
-   where "today" means the current date at report time.  The "later of"
-rule ensures that forecast transactions do not overlap normal
-transactions in time; they will begin only after normal transactions
-end.
-
-   Forecasting can be useful for estimating balances into the future,
-and experimenting with different scenarios.  Note the start date logic
-means that forecasted transactions are automatically replaced by normal
-transactions as you add those.
+   * ends on the report end date if specified with -e/-p/date:, or 6
+     months (180 days) from today.
 
-   Forecasting can also help with data entry: describe most of your
-transactions with periodic rules, and every so often copy the output of
-'print --forecast' to the journal.
+   This means that periodic transactions will begin only after the
+latest recorded transaction.  And a recorded transaction dated in the
+future can prevent generation of periodic transactions.  (You can avoid
+that by writing the future transaction as a one-time periodic rule
+instead - put tilde before the date, eg '~ YYYY-MM-DD ...').
 
-   You can generate one-time transactions too: just write a period
-expression specifying a date with no report interval.  (You could also
-write a normal transaction with a future date, but remember this
-disables forecast transactions on previous dates.)
+   Or, you can set your own arbitrary "forecast period", which can
+overlap recorded transactions, and need not be in the future, by
+providing an option argument, like '--forecast=PERIODEXPR'.  Note the
+equals sign is required, a space won't work.  PERIODEXPR is a period
+expression, which can specify the start date, end date, or both, like in
+a 'date:' query.  (See also hledger.1 -> Report start & end date).  Some
+examples: '--forecast=202001-202004', '--forecast=jan-',
+'--forecast=2020'.
 
 
 File: hledger_journal.info,  Node: Budgeting with periodic transactions,  Prev: Forecasting with periodic transactions,  Up: Periodic transactions
 
-1.13.4 Budgeting with periodic transactions
+1.14.4 Budgeting with periodic transactions
 -------------------------------------------
 
 With the '--budget' flag, currently supported by the balance command,
@@ -1653,7 +1687,7 @@
 
 File: hledger_journal.info,  Node: Auto postings,  Prev: Periodic transactions,  Up: Transactions
 
-1.14 Auto postings
+1.15 Auto postings
 ==================
 
 "Automated postings" or "auto postings" are extra postings which get
@@ -1731,7 +1765,7 @@
 
 File: hledger_journal.info,  Node: Auto postings and multiple files,  Next: Auto postings and dates,  Up: Auto postings
 
-1.14.1 Auto postings and multiple files
+1.15.1 Auto postings and multiple files
 ---------------------------------------
 
 An auto posting rule can affect any transaction in the current file, or
@@ -1741,7 +1775,7 @@
 
 File: hledger_journal.info,  Node: Auto postings and dates,  Next: Auto postings and transaction balancing / inferred amounts / balance assertions,  Prev: Auto postings and multiple files,  Up: Auto postings
 
-1.14.2 Auto postings and dates
+1.15.2 Auto postings and dates
 ------------------------------
 
 A posting date (or secondary date) in the matched posting, or (taking
@@ -1751,7 +1785,7 @@
 
 File: hledger_journal.info,  Node: Auto postings and transaction balancing / inferred amounts / balance assertions,  Next: Auto posting tags,  Prev: Auto postings and dates,  Up: Auto postings
 
-1.14.3 Auto postings and transaction balancing / inferred amounts /
+1.15.3 Auto postings and transaction balancing / inferred amounts /
 -------------------------------------------------------------------
 
 balance assertions Currently, auto postings are added:
@@ -1767,7 +1801,7 @@
 
 File: hledger_journal.info,  Node: Auto posting tags,  Prev: Auto postings and transaction balancing / inferred amounts / balance assertions,  Up: Auto postings
 
-1.14.4 Auto posting tags
+1.15.4 Auto posting tags
 ------------------------
 
 Automated postings will have some extra tags:
@@ -1789,122 +1823,124 @@
 
 Tag Table:
 Node: Top76
-Node: Transactions1873
-Ref: #transactions1965
-Node: Dates3130
-Ref: #dates3229
-Node: Simple dates3294
-Ref: #simple-dates3420
-Node: Secondary dates3929
-Ref: #secondary-dates4083
-Node: Posting dates5419
-Ref: #posting-dates5548
-Node: Status6920
-Ref: #status7041
-Node: Description8749
-Ref: #description8883
-Node: Payee and note9203
-Ref: #payee-and-note9317
-Node: Comments9652
-Ref: #comments9778
-Node: Tags10972
-Ref: #tags11087
-Node: Postings12480
-Ref: #postings12608
-Node: Virtual Postings13634
-Ref: #virtual-postings13751
-Node: Account names15056
-Ref: #account-names15197
-Node: Amounts15684
-Ref: #amounts15823
-Node: Digit group marks16737
-Ref: #digit-group-marks16885
-Node: Amount display style17823
-Ref: #amount-display-style17977
-Node: Transaction prices19138
-Ref: #transaction-prices19304
-Node: Balance Assertions21570
-Ref: #balance-assertions21750
-Node: Assertions and ordering22783
-Ref: #assertions-and-ordering22971
-Node: Assertions and included files23671
-Ref: #assertions-and-included-files23914
-Node: Assertions and multiple -f options24247
-Ref: #assertions-and-multiple--f-options24503
-Node: Assertions and commodities24635
-Ref: #assertions-and-commodities24867
-Node: Assertions and prices26024
-Ref: #assertions-and-prices26238
-Node: Assertions and subaccounts26678
-Ref: #assertions-and-subaccounts26907
-Node: Assertions and virtual postings27231
-Ref: #assertions-and-virtual-postings27473
-Node: Assertions and precision27615
-Ref: #assertions-and-precision27808
-Node: Balance Assignments28075
-Ref: #balance-assignments28249
-Node: Balance assignments and prices29413
-Ref: #balance-assignments-and-prices29585
-Node: Directives29809
-Ref: #directives29968
-Node: Directives and multiple files35649
-Ref: #directives-and-multiple-files35832
-Node: Comment blocks36496
-Ref: #comment-blocks36679
-Node: Including other files36855
-Ref: #including-other-files37035
-Node: Default year37443
-Ref: #default-year37612
-Node: Declaring commodities38019
-Ref: #declaring-commodities38202
-Node: Default commodity39875
-Ref: #default-commodity40051
-Node: Market prices40940
-Ref: #market-prices41105
-Node: Declaring accounts41946
-Ref: #declaring-accounts42122
-Node: Account comments43047
-Ref: #account-comments43210
-Node: Account subdirectives43634
-Ref: #account-subdirectives43829
-Node: Account types44142
-Ref: #account-types44326
-Node: Account display order45965
-Ref: #account-display-order46135
-Node: Rewriting accounts47286
-Ref: #rewriting-accounts47471
-Node: Basic aliases48228
-Ref: #basic-aliases48374
-Node: Regex aliases49078
-Ref: #regex-aliases49250
-Node: Combining aliases49968
-Ref: #combining-aliases50161
-Node: Aliases and multiple files51437
-Ref: #aliases-and-multiple-files51646
-Node: end aliases52225
-Ref: #end-aliases52382
-Node: Default parent account52483
-Ref: #default-parent-account52651
-Node: Periodic transactions53535
-Ref: #periodic-transactions53710
-Node: Periodic rule syntax55582
-Ref: #periodic-rule-syntax55788
-Node: Two spaces between period expression and description!56492
-Ref: #two-spaces-between-period-expression-and-description56811
-Node: Forecasting with periodic transactions57495
-Ref: #forecasting-with-periodic-transactions57800
-Node: Budgeting with periodic transactions59826
-Ref: #budgeting-with-periodic-transactions60065
-Node: Auto postings60514
-Ref: #auto-postings60654
-Node: Auto postings and multiple files62833
-Ref: #auto-postings-and-multiple-files63037
-Node: Auto postings and dates63246
-Ref: #auto-postings-and-dates63520
-Node: Auto postings and transaction balancing / inferred amounts / balance assertions63695
-Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions64046
-Node: Auto posting tags64388
-Ref: #auto-posting-tags64603
+Node: Transactions1869
+Ref: #transactions1961
+Node: Dates3245
+Ref: #dates3344
+Node: Simple dates3409
+Ref: #simple-dates3535
+Node: Secondary dates4044
+Ref: #secondary-dates4198
+Node: Posting dates5534
+Ref: #posting-dates5663
+Node: Status7035
+Ref: #status7156
+Node: Description8864
+Ref: #description8998
+Node: Payee and note9318
+Ref: #payee-and-note9432
+Node: Comments9767
+Ref: #comments9893
+Node: Tags11087
+Ref: #tags11202
+Node: Postings12595
+Ref: #postings12723
+Node: Virtual postings13749
+Ref: #virtual-postings13866
+Node: Account names15171
+Ref: #account-names15312
+Node: Amounts15799
+Ref: #amounts15938
+Node: Digit group marks17046
+Ref: #digit-group-marks17194
+Node: Amount display style18132
+Ref: #amount-display-style18286
+Node: Transaction prices19723
+Ref: #transaction-prices19895
+Node: Lot prices and lot dates22227
+Ref: #lot-prices-and-lot-dates22424
+Node: Balance assertions22912
+Ref: #balance-assertions23098
+Node: Assertions and ordering24131
+Ref: #assertions-and-ordering24319
+Node: Assertions and included files25019
+Ref: #assertions-and-included-files25262
+Node: Assertions and multiple -f options25595
+Ref: #assertions-and-multiple--f-options25851
+Node: Assertions and commodities25983
+Ref: #assertions-and-commodities26215
+Node: Assertions and prices27372
+Ref: #assertions-and-prices27586
+Node: Assertions and subaccounts28026
+Ref: #assertions-and-subaccounts28255
+Node: Assertions and virtual postings28579
+Ref: #assertions-and-virtual-postings28821
+Node: Assertions and precision28963
+Ref: #assertions-and-precision29156
+Node: Balance assignments29423
+Ref: #balance-assignments29597
+Node: Balance assignments and prices30761
+Ref: #balance-assignments-and-prices30933
+Node: Directives31157
+Ref: #directives31316
+Node: Directives and multiple files37007
+Ref: #directives-and-multiple-files37190
+Node: Comment blocks37854
+Ref: #comment-blocks38037
+Node: Including other files38213
+Ref: #including-other-files38393
+Node: Default year39044
+Ref: #default-year39213
+Node: Declaring commodities39620
+Ref: #declaring-commodities39803
+Node: Default commodity41609
+Ref: #default-commodity41795
+Node: Declaring market prices42684
+Ref: #declaring-market-prices42879
+Node: Declaring accounts43736
+Ref: #declaring-accounts43922
+Node: Account comments44847
+Ref: #account-comments45010
+Node: Account subdirectives45434
+Ref: #account-subdirectives45629
+Node: Account types45942
+Ref: #account-types46126
+Node: Account display order47765
+Ref: #account-display-order47935
+Node: Rewriting accounts49086
+Ref: #rewriting-accounts49271
+Node: Basic aliases50028
+Ref: #basic-aliases50174
+Node: Regex aliases50878
+Ref: #regex-aliases51050
+Node: Combining aliases51768
+Ref: #combining-aliases51961
+Node: Aliases and multiple files53237
+Ref: #aliases-and-multiple-files53446
+Node: end aliases54025
+Ref: #end-aliases54182
+Node: Default parent account54283
+Ref: #default-parent-account54451
+Node: Periodic transactions55335
+Ref: #periodic-transactions55510
+Node: Periodic rule syntax57382
+Ref: #periodic-rule-syntax57588
+Node: Two spaces between period expression and description!58292
+Ref: #two-spaces-between-period-expression-and-description58611
+Node: Forecasting with periodic transactions59295
+Ref: #forecasting-with-periodic-transactions59600
+Node: Budgeting with periodic transactions61655
+Ref: #budgeting-with-periodic-transactions61894
+Node: Auto postings62343
+Ref: #auto-postings62483
+Node: Auto postings and multiple files64662
+Ref: #auto-postings-and-multiple-files64866
+Node: Auto postings and dates65075
+Ref: #auto-postings-and-dates65349
+Node: Auto postings and transaction balancing / inferred amounts / balance assertions65524
+Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions65875
+Node: Auto posting tags66217
+Ref: #auto-posting-tags66432
 
 End Tag Table
 
diff --git a/embeddedfiles/hledger_journal.txt b/embeddedfiles/hledger_journal.txt
--- a/embeddedfiles/hledger_journal.txt
+++ b/embeddedfiles/hledger_journal.txt
@@ -57,7 +57,8 @@
          line, and any following indented lines beginning with a semicolon)
 
        o 0 or more indented posting lines, describing what was transferred and
-         the accounts involved.
+         the  accounts  involved (indented comment lines are also allowed, but
+         not blank lines or non-indented lines).
 
        Here's a simple journal file containing one transaction:
 
@@ -67,35 +68,35 @@
 
    Dates
    Simple dates
-       Dates  in  the  journal  file  use  simple  dates format: YYYY-MM-DD or
+       Dates in the journal  file  use  simple  dates  format:  YYYY-MM-DD  or
        YYYY/MM/DD or YYYY.MM.DD, with leading zeros optional.  The year may be
-       omitted,  in  which case it will be inferred from the context: the cur-
-       rent transaction, the default year set with a default  year  directive,
-       or   the  current  date  when  the  command  is  run.   Some  examples:
+       omitted, in which case it will be inferred from the context:  the  cur-
+       rent  transaction,  the default year set with a default year directive,
+       or  the  current  date  when  the  command  is  run.   Some   examples:
        2010-01-31, 2010/01/31, 2010.1.31, 1/31.
 
-       (The UI also accepts simple dates, as well as the more  flexible  smart
+       (The  UI  also accepts simple dates, as well as the more flexible smart
        dates documented in the hledger manual.)
 
    Secondary dates
-       Real-life  transactions  sometimes  involve more than one date - eg the
+       Real-life transactions sometimes involve more than one date  -  eg  the
        date you write a cheque, and the date it clears in your bank.  When you
-       want  to  model this, for more accurate daily balances, you can specify
+       want to model this, for more accurate daily balances, you  can  specify
        individual posting dates.
 
-       Or, you can use the older secondary date feature (Ledger calls it  aux-
-       iliary  date or effective date).  Note: we support this for compatibil-
-       ity, but I usually recommend avoiding this feature; posting  dates  are
+       Or,  you can use the older secondary date feature (Ledger calls it aux-
+       iliary date or effective date).  Note: we support this for  compatibil-
+       ity,  but  I usually recommend avoiding this feature; posting dates are
        almost always clearer and simpler.
 
        A secondary date is written after the primary date, following an equals
-       sign.  If the year is omitted, the  primary  date's  year  is  assumed.
-       When  running  reports, the primary (left) date is used by default, but
-       with the --date2 flag (or --aux-date  or  --effective),  the  secondary
+       sign.   If  the  year  is  omitted, the primary date's year is assumed.
+       When running reports, the primary (left) date is used by  default,  but
+       with  the  --date2  flag  (or --aux-date or --effective), the secondary
        (right) date will be used instead.
 
-       The  meaning of secondary dates is up to you, but it's best to follow a
-       consistent rule.  Eg "primary = the bank's clearing date,  secondary  =
+       The meaning of secondary dates is up to you, but it's best to follow  a
+       consistent  rule.   Eg "primary = the bank's clearing date, secondary =
        date the transaction was initiated, if different", as shown here:
 
               2010/2/23=2/19 movie ticket
@@ -109,11 +110,11 @@
               2010-02-19 movie ticket         assets:checking                $-10         $-10
 
    Posting dates
-       You  can  give  individual  postings a different date from their parent
-       transaction, by adding a posting comment containing a tag  (see  below)
+       You can give individual postings a different  date  from  their  parent
+       transaction,  by  adding a posting comment containing a tag (see below)
        like date:DATE.  This is probably the best way to control posting dates
-       precisely.  Eg in this example the expense should  appear  in  May  re-
-       ports,  and  the  deduction from checking should be reported on 6/1 for
+       precisely.   Eg  in  this  example the expense should appear in May re-
+       ports, and the deduction from checking should be reported  on  6/1  for
        easy bank reconciliation:
 
               2015/5/30
@@ -126,22 +127,22 @@
               $ hledger -f t.j register checking
               2015-06-01                      assets:checking               $-10          $-10
 
-       DATE should be a simple date; if the year is not specified it will  use
-       the  year  of  the  transaction's date.  You can set the secondary date
-       similarly, with date2:DATE2.  The date: or  date2:  tags  must  have  a
-       valid  simple  date  value  if they are present, eg a date: tag with no
+       DATE  should be a simple date; if the year is not specified it will use
+       the year of the transaction's date.  You can  set  the  secondary  date
+       similarly,  with  date2:DATE2.   The  date:  or date2: tags must have a
+       valid simple date value if they are present, eg a  date:  tag  with  no
        value is not allowed.
 
        Ledger's earlier, more compact bracketed date syntax is also supported:
-       [DATE],  [DATE=DATE2]  or  [=DATE2].  hledger will attempt to parse any
+       [DATE], [DATE=DATE2] or [=DATE2].  hledger will attempt  to  parse  any
        square-bracketed sequence of the 0123456789/-.= characters in this way.
-       With  this  syntax, DATE infers its year from the transaction and DATE2
+       With this syntax, DATE infers its year from the transaction  and  DATE2
        infers its year from DATE.
 
    Status
-       Transactions, or individual postings within a transaction, can  have  a
-       status  mark,  which  is  a single character before the transaction de-
-       scription or posting account name, separated from it by a space,  indi-
+       Transactions,  or  individual postings within a transaction, can have a
+       status mark, which is a single character  before  the  transaction  de-
+       scription  or posting account name, separated from it by a space, indi-
        cating one of three statuses:
 
        mark     status
@@ -150,23 +151,23 @@
        !        pending
        *        cleared
 
-       When  reporting,  you  can  filter  by  status  with the -U/--unmarked,
-       -P/--pending, and -C/--cleared flags; or  the  status:,  status:!,  and
+       When reporting, you  can  filter  by  status  with  the  -U/--unmarked,
+       -P/--pending,  and  -C/--cleared  flags;  or the status:, status:!, and
        status:* queries; or the U, P, C keys in hledger-ui.
 
-       Note,  in Ledger and in older versions of hledger, the "unmarked" state
-       is called "uncleared".  As of hledger 1.3 we have  renamed  it  to  un-
+       Note, in Ledger and in older versions of hledger, the "unmarked"  state
+       is  called  "uncleared".   As  of hledger 1.3 we have renamed it to un-
        marked for clarity.
 
-       To  replicate Ledger and old hledger's behaviour of also matching pend-
+       To replicate Ledger and old hledger's behaviour of also matching  pend-
        ing, combine -U and -P.
 
-       Status marks are optional, but can be helpful eg for  reconciling  with
+       Status  marks  are optional, but can be helpful eg for reconciling with
        real-world accounts.  Some editor modes provide highlighting and short-
-       cuts for working with status.  Eg in Emacs ledger-mode, you can  toggle
+       cuts  for working with status.  Eg in Emacs ledger-mode, you can toggle
        transaction status with C-c C-e, or posting status with C-c C-c.
 
-       What  "uncleared", "pending", and "cleared" actually mean is up to you.
+       What "uncleared", "pending", and "cleared" actually mean is up to  you.
        Here's one suggestion:
 
        status       meaning
@@ -177,34 +178,34 @@
        cleared      complete, reconciled as far as possible, and considered cor-
                     rect
 
-       With this scheme, you would use -PC to see the current balance at  your
+       With  this scheme, you would use -PC to see the current balance at your
        bank, -U to see things which will probably hit your bank soon (like un-
-       cashed checks), and no flags to see the most up-to-date state  of  your
+       cashed  checks),  and no flags to see the most up-to-date state of your
        finances.
 
    Description
-       A  transaction's description is the rest of the line following the date
-       and status mark (or until a  comment  begins).   Sometimes  called  the
+       A transaction's description is the rest of the line following the  date
+       and  status  mark  (or  until  a comment begins).  Sometimes called the
        "narration" in traditional bookkeeping, it can be used for whatever you
-       wish, or left blank.  Transaction descriptions can be  queried,  unlike
+       wish,  or  left blank.  Transaction descriptions can be queried, unlike
        comments.
 
    Payee and note
        You can optionally include a | (pipe) character in descriptions to sub-
        divide the description into separate fields for payee/payer name on the
        left (up to the first |) and an additional note field on the right (af-
-       ter the first |).  This may be worthwhile if you need to do  more  pre-
+       ter  the  first |).  This may be worthwhile if you need to do more pre-
        cise querying and pivoting by payee or by note.
 
    Comments
        Lines in the journal beginning with a semicolon (;) or hash (#) or star
-       (*) are comments, and will be ignored.  (Star comments  cause  org-mode
-       nodes  to  be  ignored, allowing emacs users to fold and navigate their
+       (*)  are  comments, and will be ignored.  (Star comments cause org-mode
+       nodes to be ignored, allowing emacs users to fold  and  navigate  their
        journals with org-mode or orgstruct-mode.)
 
-       You can attach comments to a transaction by writing them after the  de-
+       You  can attach comments to a transaction by writing them after the de-
        scription and/or indented on the following lines (before the postings).
-       Similarly, you can attach comments to an individual posting by  writing
+       Similarly,  you can attach comments to an individual posting by writing
        them after the amount and/or indented on the following lines.  Transac-
        tion and posting comments must begin with a semicolon (;).
 
@@ -228,24 +229,24 @@
                   ; another comment line for posting 2
               ; a file comment (because not indented)
 
-       You can also comment larger regions of a file  using  comment  and  end
+       You  can  also  comment  larger regions of a file using comment and end
        comment directives.
 
    Tags
-       Tags  are  a  way  to add extra labels or labelled data to postings and
+       Tags are a way to add extra labels or labelled  data  to  postings  and
        transactions, which you can then search or pivot on.
 
-       A simple tag is a word (which may contain hyphens) followed by  a  full
+       A  simple  tag is a word (which may contain hyphens) followed by a full
        colon, written inside a transaction or posting comment line:
 
               2017/1/16 bought groceries  ; sometag:
 
-       Tags  can  have  a  value, which is the text after the colon, up to the
+       Tags can have a value, which is the text after the  colon,  up  to  the
        next comma or end of line, with leading/trailing whitespace removed:
 
                   expenses:food    $10 ; a-posting-tag: the tag value
 
-       Note this means hledger's tag values can not  contain  commas  or  new-
+       Note  this  means  hledger's  tag values can not contain commas or new-
        lines.  Ending at commas means you can write multiple short tags on one
        line, comma separated:
 
@@ -259,57 +260,57 @@
 
        o "tag2" is another tag, whose value is "some value ..."
 
-       Tags in a transaction comment affect the transaction  and  all  of  its
-       postings,  while  tags  in  a posting comment affect only that posting.
-       For example, the following transaction has three tags (A, TAG2,  third-
+       Tags  in  a  transaction  comment affect the transaction and all of its
+       postings, while tags in a posting comment  affect  only  that  posting.
+       For  example, the following transaction has three tags (A, TAG2, third-
        tag) and the posting has four (those plus posting-tag):
 
               1/1 a transaction  ; A:, TAG2:
                   ; third-tag: a third transaction tag, <- with a value
                   (a)  $1  ; posting-tag:
 
-       Tags  are  like  Ledger's metadata feature, except hledger's tag values
+       Tags are like Ledger's metadata feature, except  hledger's  tag  values
        are simple strings.
 
    Postings
-       A posting is an addition of some amount to, or removal of  some  amount
-       from,  an account.  Each posting line begins with at least one space or
+       A  posting  is an addition of some amount to, or removal of some amount
+       from, an account.  Each posting line begins with at least one space  or
        tab (2 or 4 spaces is common), followed by:
 
        o (optional) a status character (empty, !, or *), followed by a space
 
-       o (required) an account name (any text,  optionally  containing  single
+       o (required)  an  account  name (any text, optionally containing single
          spaces, until end of line or a double space)
 
        o (optional) two or more spaces or tabs followed by an amount.
 
-       Positive  amounts  are being added to the account, negative amounts are
+       Positive amounts are being added to the account, negative  amounts  are
        being removed.
 
        The amounts within a transaction must always sum up to zero.  As a con-
-       venience,  one  amount  may be left blank; it will be inferred so as to
+       venience, one amount may be left blank; it will be inferred  so  as  to
        balance the transaction.
 
-       Be sure to note the unusual two-space delimiter  between  account  name
-       and  amount.  This makes it easy to write account names containing spa-
-       ces.  But if you accidentally leave only one space (or tab) before  the
+       Be  sure  to  note the unusual two-space delimiter between account name
+       and amount.  This makes it easy to write account names containing  spa-
+       ces.   But if you accidentally leave only one space (or tab) before the
        amount, the amount will be considered part of the account name.
 
-   Virtual Postings
+   Virtual postings
        A posting with a parenthesised account name is called a virtual posting
-       or unbalanced posting, which means it is exempt  from  the  usual  rule
+       or  unbalanced  posting,  which  means it is exempt from the usual rule
        that a transaction's postings must balance add up to zero.
 
-       This  is  not  part  of double entry accounting, so you might choose to
-       avoid this feature.  Or you can use it sparingly  for  certain  special
-       cases  where  it can be convenient.  Eg, you could set opening balances
+       This is not part of double entry accounting, so  you  might  choose  to
+       avoid  this  feature.   Or you can use it sparingly for certain special
+       cases where it can be convenient.  Eg, you could set  opening  balances
        without using a balancing equity account:
 
               1/1 opening balances
                 (assets:checking)   $1000
                 (assets:savings)    $2000
 
-       A posting with a bracketed account name is called  a  balanced  virtual
+       A  posting  with  a bracketed account name is called a balanced virtual
        posting.  The balanced virtual postings in a transaction must add up to
        zero (separately from other postings).  Eg:
 
@@ -321,34 +322,34 @@
                 [assets:checking:available]     $10    ; <-
                 (something:else)                 $5       ; <- not required to balance
 
-       Ordinary non-parenthesised,  non-bracketed  postings  are  called  real
-       postings.   You  can  exclude  virtual  postings  from reports with the
+       Ordinary  non-parenthesised,  non-bracketed  postings  are  called real
+       postings.  You can exclude  virtual  postings  from  reports  with  the
        -R/--real flag or real:1 query.
 
    Account names
-       Account names typically have several parts separated by a  full  colon,
-       from  which hledger derives a hierarchical chart of accounts.  They can
-       be anything you like, but in finance there are traditionally five  top-
+       Account  names  typically have several parts separated by a full colon,
+       from which hledger derives a hierarchical chart of accounts.  They  can
+       be  anything you like, but in finance there are traditionally five top-
        level accounts: assets, liabilities, income, expenses, and equity.
 
-       Account  names  may  contain single spaces, eg: assets:accounts receiv-
-       able.  Because of this, they must always be followed  by  two  or  more
+       Account names may contain single spaces,  eg:  assets:accounts  receiv-
+       able.   Because  of  this,  they must always be followed by two or more
        spaces (or newline).
 
        Account names can be aliased.
 
    Amounts
-       After  the  account  name, there is usually an amount.  (Important: be-
+       After the account name, there is usually an  amount.   (Important:  be-
        tween account name and amount, there must be two or more spaces.)
 
-       hledger's amount format is flexible, supporting  several  international
-       formats.   Here  are  some examples.  Amounts have a number (the "quan-
+       hledger's  amount  format is flexible, supporting several international
+       formats.  Here are some examples.  Amounts have a  number  (the  "quan-
        tity"):
 
               1
 
-       ..and usually a currency or commodity name (the "commodity").  This  is
-       a  symbol,  word, or phrase, to the left or right of the quantity, with
+       ..and  usually a currency or commodity name (the "commodity").  This is
+       a symbol, word, or phrase, to the left or right of the  quantity,  with
        or without a separating space:
 
               $1
@@ -359,12 +360,19 @@
 
               3 "no. 42 green apples"
 
-       Amounts can be negative.  The minus sign can be written before or after
-       a left-side commodity symbol:
+       Amounts can be preceded by a minus sign (or a plus sign, though plus is
+       the  default), The sign can be written before or after a left-side com-
+       modity symbol:
 
               -$1
               $-1
 
+       One or more spaces between the sign and the number are acceptable  when
+       parsing (but they won't be displayed in output):
+
+              + $1
+              $-      1
+
        Scientific E notation is allowed:
 
               1E-6
@@ -376,8 +384,8 @@
               1,23456780000009
 
    Digit group marks
-       In the integer part of the quantity (left of the decimal mark),  groups
-       of  digits  can  optionally  be  separated  by a "digit group mark" - a
+       In  the integer part of the quantity (left of the decimal mark), groups
+       of digits can optionally be separated by  a  "digit  group  mark"  -  a
        space, comma, or period (different from the decimal mark):
 
                    $1,000,000.00
@@ -385,7 +393,7 @@
               INR 9,99,99,999.00
                     1 000 000.9455
 
-       Note, a number containing a single group mark and no  decimal  mark  is
+       Note,  a  number  containing a single group mark and no decimal mark is
        ambiguous.  Are these group marks or decimal marks ?
 
               1,000
@@ -393,9 +401,9 @@
 
        hledger will treat them both as decimal marks by default (cf #793).  If
        you use digit group marks, to prevent confusion and undetected typos we
-       recommend  you write commodity directives at the top of the file to ex-
-       plicitly declare the decimal mark (and optionally a digit group  mark).
-       Note,  these  formats ("amount styles") are specific to each commodity,
+       recommend you write commodity directives at the top of the file to  ex-
+       plicitly  declare the decimal mark (and optionally a digit group mark).
+       Note, these formats ("amount styles") are specific to  each  commodity,
        so if your data uses multiple formats, hledger can handle it:
 
               commodity $1,000.00
@@ -404,31 +412,36 @@
               commodity       1 000 000.9455
 
    Amount display style
-       For each commodity, hledger chooses a consistent  format  to  use  when
-       displaying  amounts.  (Except price amounts, which are always displayed
+       For  each  commodity,  hledger  chooses a consistent format to use when
+       displaying amounts.  (Except price amounts, which are always  displayed
        as written).  The display style is chosen as follows:
 
-       o If there is a commodity directive (or  default  commodity  directive)
+       o If  there  is  a commodity directive (or default commodity directive)
          for the commodity, that format is used (see examples above).
 
-       o Otherwise  the  format  of the first posting amount in that commodity
+       o Otherwise the format of the first posting amount  in  that  commodity
          seen in the journal is used.  But the number of decimal places ("pre-
-         cision")  will  be the maximum from all posting amounts in that comm-
-         modity.
+         cision") will be the maximum from all posting amounts in that commod-
+         ity.
 
-       o Or if there are no such amounts in the journal, a default  format  is
+       o Or  if  there are no such amounts in the journal, a default format is
          used (like $1000.00).
 
-       Transaction  prices don't affect the amount display style directly, but
-       occasionally they can do so indirectly (eg when an posting's amount  is
-       inferred  using  a  transaction price).  If you find this causing prob-
+       Transaction prices don't affect the amount display style directly,  but
+       occasionally  they can do so indirectly (eg when an posting's amount is
+       inferred using a transaction price).  If you find  this  causing  prob-
        lems, use a commodity directive to fix the display style.
 
        In summary: amounts will be displayed much as they appear in your jour-
-       nal,  with  the  max observed number of decimal places.  If you want to
+       nal, with the max observed number of decimal places.  If  you  want  to
        see fewer decimal places in reports, use a commodity directive to over-
        ride that.
 
+       hledger uses banker's rounding: it rounds to the nearest  even  number,
+       eg  0.5  displayed  with  zero decimal places is "0").  (Note, prior to
+       hledger 1.17.1 this could vary if hledger happened to be built with  an
+       old version of Decimal (<0.5.1); since 1.17.1 it's guaranteed.)
+
    Transaction prices
        Within a transaction, you can note an amount's price in another commod-
        ity.  This can be used to document the cost (in a purchase) or  selling
@@ -459,10 +472,11 @@
                     assets:euros     EUR100          ; one hundred euros purchased
                     assets:dollars  $-135          ; for $135
 
-       (Ledger users: Ledger uses a different syntax for fixed prices, {=UNIT-
-       PRICE}, which hledger currently ignores).
+       5. Like 1 and 2, but the @ or @@ is parenthesised; this is for compati-
+          bility  with Ledger journals (Virtual posting costs), and in hledger
+          is equivalent to 1 and 2.
 
-       Use  the -B/--cost flag to convert amounts to their transaction price's
+       Use the -B/--cost flag to convert amounts to their transaction  price's
        commodity, if any.  (mnemonic: "B" is from "cost Basis", as in Ledger).
        Eg here is how -B affects the balance report for the example above:
 
@@ -473,8 +487,8 @@
                              $-135  assets:dollars
                               $135  assets:euros    # <- the euros' cost
 
-       Note  -B is sensitive to the order of postings when a transaction price
-       is inferred: the inferred price will be in the commodity  of  the  last
+       Note -B is sensitive to the order of postings when a transaction  price
+       is  inferred:  the  inferred price will be in the commodity of the last
        amount.  So if example 3's postings are reversed, while the transaction
        is equivalent, -B shows something different:
 
@@ -486,10 +500,19 @@
                              EUR-100  assets:dollars  # <- the dollars' selling price
                               EUR100  assets:euros
 
-   Balance Assertions
-       hledger supports Ledger-style  balance  assertions  in  journal  files.
-       These  look  like, for example, = EXPECTEDBALANCE following a posting's
-       amount.  Eg here we assert the expected dollar balance  in  accounts  a
+   Lot prices and lot dates
+       Ledger  allows  another kind of price, lot price (four variants: {UNIT-
+       PRICE},   {{TOTALPRICE}},   {=FIXEDUNITPRICE},   {{=FIXEDTOTALPRICE}}),
+       and/or a lot date ([DATE]) to be specified.  These are normally used to
+       select a lot when selling investments.  hledger will parse  these,  for
+       compatibility  with  Ledger  journals,  but  currently ignores them.  A
+       transaction price, lot price and/or lot date may appear in  any  order,
+       after the posting amount and before the balance assertion if any.
+
+   Balance assertions
+       hledger  supports  Ledger-style  balance  assertions  in journal files.
+       These look like, for example, = EXPECTEDBALANCE following  a  posting's
+       amount.   Eg  here  we assert the expected dollar balance in accounts a
        and b after each posting:
 
               2013/1/1
@@ -501,32 +524,32 @@
                 b  $-1  =$-2
 
        After reading a journal file, hledger will check all balance assertions
-       and report an error if any of them fail.  Balance assertions  can  pro-
-       tect  you  from, eg, inadvertently disrupting reconciled balances while
-       cleaning up old entries.  You can disable  them  temporarily  with  the
+       and  report  an error if any of them fail.  Balance assertions can pro-
+       tect you from, eg, inadvertently disrupting reconciled  balances  while
+       cleaning  up  old  entries.   You can disable them temporarily with the
        -I/--ignore-assertions flag, which can be useful for troubleshooting or
-       for reading Ledger files.  (Note: this flag currently does not  disable
+       for  reading Ledger files.  (Note: this flag currently does not disable
        balance assignments, below).
 
    Assertions and ordering
-       hledger  sorts  an  account's postings and assertions first by date and
-       then (for postings on the same day) by parse order.  Note this is  dif-
+       hledger sorts an account's postings and assertions first  by  date  and
+       then  (for postings on the same day) by parse order.  Note this is dif-
        ferent from Ledger, which sorts assertions only by parse order.  (Also,
-       Ledger assertions do not see the accumulated effect of  repeated  post-
+       Ledger  assertions  do not see the accumulated effect of repeated post-
        ings to the same account within a transaction.)
 
        So, hledger balance assertions keep working if you reorder differently-
-       dated transactions within the journal.  But if you  reorder  same-dated
-       transactions  or postings, assertions might break and require updating.
+       dated  transactions  within the journal.  But if you reorder same-dated
+       transactions or postings, assertions might break and require  updating.
        This order dependence does bring an advantage: precise control over the
        order of postings and assertions within a day, so you can assert intra-
        day balances.
 
    Assertions and included files
-       With included files, things are a little more  complicated.   Including
-       preserves  the ordering of postings and assertions.  If you have multi-
-       ple postings to an account on the  same  day,  split  across  different
-       files,  and  you  also want to assert the account's balance on the same
+       With  included  files, things are a little more complicated.  Including
+       preserves the ordering of postings and assertions.  If you have  multi-
+       ple  postings  to  an  account  on the same day, split across different
+       files, and you also want to assert the account's balance  on  the  same
        day, you'll have to put the assertion in the right file.
 
    Assertions and multiple -f options
@@ -534,15 +557,15 @@
        -f options.  Use include or concatenate the files instead.
 
    Assertions and commodities
-       The  asserted  balance must be a simple single-commodity amount, and in
-       fact the assertion checks only  this  commodity's  balance  within  the
-       (possibly  multi-commodity)  account  balance.   This is how assertions
+       The asserted balance must be a simple single-commodity amount,  and  in
+       fact  the  assertion  checks  only  this commodity's balance within the
+       (possibly multi-commodity) account balance.   This  is  how  assertions
        work in Ledger also.  We could call this a "partial" balance assertion.
 
        To assert the balance of more than one commodity in an account, you can
        write multiple postings, each asserting one commodity's balance.
 
-       You  can  make a stronger "total" balance assertion by writing a double
+       You can make a stronger "total" balance assertion by writing  a  double
        equals sign (== EXPECTEDBALANCE).  This asserts that there are no other
        unasserted commodities in the account (or, that their balance is 0).
 
@@ -562,7 +585,7 @@
                 a    0 ==  $1
 
        It's not yet possible to make a complete assertion about a balance that
-       has multiple commodities.  One workaround is to isolate each  commodity
+       has  multiple commodities.  One workaround is to isolate each commodity
        into its own subaccount:
 
               2013/1/1
@@ -576,21 +599,21 @@
                 a:euro   0 ==  1EUR
 
    Assertions and prices
-       Balance  assertions  ignore  transaction prices, and should normally be
+       Balance assertions ignore transaction prices, and  should  normally  be
        written without one:
 
               2019/1/1
                 (a)     $1 @ EUR1 = $1
 
-       We do allow prices to be written there, however, and print shows  them,
-       even  though  they  don't affect whether the assertion passes or fails.
-       This is for backward compatibility (hledger's  close  command  used  to
-       generate  balance  assertions with prices), and because balance assign-
+       We  do allow prices to be written there, however, and print shows them,
+       even though they don't affect whether the assertion  passes  or  fails.
+       This  is  for  backward  compatibility (hledger's close command used to
+       generate balance assertions with prices), and because  balance  assign-
        ments do use them (see below).
 
    Assertions and subaccounts
-       The balance assertions above (= and ==) do not count the  balance  from
-       subaccounts;  they check the account's exclusive balance only.  You can
+       The  balance  assertions above (= and ==) do not count the balance from
+       subaccounts; they check the account's exclusive balance only.  You  can
        assert the balance including subaccounts by writing =* or ==*, eg:
 
               2019/1/1
@@ -604,16 +627,16 @@
        tual.  They are not affected by the --real/-R flag or real: query.
 
    Assertions and precision
-       Balance  assertions  compare  the exactly calculated amounts, which are
-       not always what is shown by reports.   Eg  a  commodity  directive  may
-       limit  the  display  precision, but this will not affect balance asser-
+       Balance assertions compare the exactly calculated  amounts,  which  are
+       not  always  what  is  shown  by reports.  Eg a commodity directive may
+       limit the display precision, but this will not  affect  balance  asser-
        tions.  Balance assertion failure messages show exact amounts.
 
-   Balance Assignments
-       Ledger-style balance assignments are also supported.   These  are  like
-       balance  assertions, but with no posting amount on the left side of the
-       equals sign; instead it is calculated automatically so  as  to  satisfy
-       the  assertion.   This  can be a convenience during data entry, eg when
+   Balance assignments
+       Ledger-style  balance  assignments  are also supported.  These are like
+       balance assertions, but with no posting amount on the left side of  the
+       equals  sign;  instead  it is calculated automatically so as to satisfy
+       the assertion.  This can be a convenience during data  entry,  eg  when
        setting opening balances:
 
               ; starting a new journal, set asset account balances
@@ -631,14 +654,14 @@
                 expenses:misc
 
        The calculated amount depends on the account's balance in the commodity
-       at  that  point  (which depends on the previously-dated postings of the
-       commodity to that account since the last balance assertion  or  assign-
+       at that point (which depends on the previously-dated  postings  of  the
+       commodity  to  that account since the last balance assertion or assign-
        ment).  Note that using balance assignments makes your journal a little
        less explicit; to know the exact amount posted, you have to run hledger
        or do the calculations yourself, instead of just reading it.
 
    Balance assignments and prices
-       A  transaction  price in a balance assignment will cause the calculated
+       A transaction price in a balance assignment will cause  the  calculated
        amount to have that price attached:
 
               2019/1/1
@@ -649,85 +672,87 @@
                   (a)         $1 @ EUR2 = $1 @ EUR2
 
    Directives
-       A directive is a line in the journal beginning with a special  keyword,
+       A  directive is a line in the journal beginning with a special keyword,
        that influences how the journal is processed.  hledger's directives are
        based on a subset of Ledger's, but there are many differences (and also
        some differences between hledger versions).
 
        Directives' behaviour and interactions can get a little bit complex, so
-       here is a table summarising the  directives  and  their  effects,  with
+       here  is  a  table  summarising  the directives and their effects, with
        links to more detailed docs.
 
-       direc-     end   di-   subdi-    purpose                        can  affect  (as of
+       direc-     end   di-   subdi-    purpose                        can affect  (as  of
        tive       rective     rec-                                     2018/06)
                               tives
        ------------------------------------------------------------------------------------
-       account                any       document  account names, de-   all  entries in all
-                              text      clare account types  &  dis-   files,  before   or
+       account                any       document account names,  de-   all entries in  all
+                              text      clare  account  types & dis-   files,   before  or
                                         play order                     after
        alias      end                   rewrite account names          following       in-
                   aliases                                              line/included   en-
-                                                                       tries until end  of
+                                                                       tries  until end of
                                                                        current file or end
                                                                        directive
-       apply      end apply             prepend a common  parent  to   following       in-
+       apply      end apply             prepend  a  common parent to   following       in-
        account    account               account names                  line/included   en-
-                                                                       tries  until end of
+                                                                       tries until end  of
                                                                        current file or end
                                                                        directive
        comment    end  com-             ignore part of journal         following       in-
                   ment                                                 line/included   en-
-                                                                       tries until end  of
+                                                                       tries  until end of
                                                                        current file or end
                                                                        directive
-       commod-                format    declare  a commodity and its   number    notation:
+       commod-                format    declare a commodity and  its   number    notation:
        ity                              number  notation  &  display   following   entries
                                         style                          in  that  commodity
-                                                                       in all files;  dis-
+                                                                       in  all files; dis-
                                                                        play style: amounts
                                                                        of  that  commodity
                                                                        in reports
-       D                                declare  a  commodity  to be   default  commodity:
+       D                                declare a  commodity  to  be   default  commodity:
                                         used    for    commodityless   following   commod-
-                                        amounts,  and its number no-   ityless entries un-
-                                        tation & display style         til  end of current
-                                                                       file; number  nota-
+                                        amounts, and its number  no-   ityless entries un-
+                                        tation & display style         til end of  current
+                                                                       file;  number nota-
                                                                        tion: following en-
-                                                                       tries in that  com-
+                                                                       tries  in that com-
                                                                        modity until end of
-                                                                       current file;  dis-
+                                                                       current  file; dis-
                                                                        play style: amounts
                                                                        of  that  commodity
                                                                        in reports
        include                          include   entries/directives   what  the  included
                                         from another file              directives affect
        P                                declare a market price for a   amounts   of   that
-                                        commodity                      commodity   in  re-
-                                                                       ports, when  -V  is
+                                        commodity                      commodity  in   re-
+                                                                       ports,  when  -V is
                                                                        used
-       Y                                declare  a year for yearless   following       in-
+
+
+
+       Y                                declare a year for  yearless   following       in-
                                         dates                          line/included   en-
-                                                                       tries until end  of
+                                                                       tries  until end of
                                                                        current file
-       =                                declare   an   auto  posting   all entries in par-
-                                        rule,  adding  postings   to   ent/current/child
+       =                                declare  an   auto   posting   all entries in par-
+                                        rule,   adding  postings  to   ent/current/child
                                         other transactions             files (but not sib-
                                                                        ling   files,   see
                                                                        #1212)
 
        And some definitions:
 
-       subdi-   optional  indented directive line immediately following a parent
+       subdi-   optional indented directive line immediately following a  parent
        rec-     directive
        tive
        number   how to interpret numbers when parsing journal entries (the iden-
-       nota-    tity  of the decimal separator character).  (Currently each com-
+       nota-    tity of the decimal separator character).  (Currently each  com-
        tion     modity can have its own notation, even in the same file.)
-
-       dis-     how to display amounts of a commodity in  reports  (symbol  side
+       dis-     how  to  display  amounts of a commodity in reports (symbol side
        play     and spacing, digit groups, decimal separator, decimal places)
        style
-       direc-   which  entries  and  (when there are multiple files) which files
+       direc-   which entries and (when there are multiple  files)  which  files
        tive     are affected by a directive
        scope
 
@@ -736,41 +761,49 @@
        ports).  Some directives have multiple effects.
 
    Directives and multiple files
-       If you use  multiple  -f/--file  options,  or  the  include  directive,
-       hledger  will  process  multiple input files.  But note that directives
+       If  you  use  multiple  -f/--file  options,  or  the include directive,
+       hledger will process multiple input files.  But  note  that  directives
        which affect input (see above) typically last only until the end of the
        file in which they occur.
 
        This may seem inconvenient, but it's intentional; it makes reports sta-
-       ble and deterministic, independent of the order  of  input.   Otherwise
-       you  could see different numbers if you happened to write -f options in
-       a different order, or if you moved includes around  while  cleaning  up
+       ble  and  deterministic,  independent of the order of input.  Otherwise
+       you could see different numbers if you happened to write -f options  in
+       a  different  order,  or if you moved includes around while cleaning up
        your files.
 
-       It  can  be  surprising though; for example, it means that alias direc-
+       It can be surprising though; for example, it means  that  alias  direc-
        tives do not affect parent or sibling files (see below).
 
    Comment blocks
-       A line containing just comment starts a commented region of  the  file,
+       A  line  containing just comment starts a commented region of the file,
        and a line containing just end comment (or the end of the current file)
        ends it.  See also comments.
 
    Including other files
-       You can pull in the content of additional files by writing  an  include
+       You  can  pull in the content of additional files by writing an include
        directive, like this:
 
-              include path/to/file.journal
+              include FILEPATH
 
-       If  the path does not begin with a slash, it is relative to the current
-       file.  The include file path may contain  common  glob  patterns  (e.g.
-       *).
+       Only journal files can include, and only journal, timeclock or  timedot
+       files can be included (not CSV files, currently).
 
-       The  include  directive  can only be used in journal files.  It can in-
-       clude journal, timeclock or timedot files, but not CSV files.
+       If  the  file  path  does not begin with a slash, it is relative to the
+       current file's folder.
 
+       It may contain glob patterns  to  match  multiple  files,  eg:  include
+       *.journal.
+
+       Or a tilde, meaning home directory: include ~/main.journal.
+
+       It may also be prefixed to force a specific file format, overriding the
+       file extension (as described in  hledger.1  ->  Input  files):  include
+       timedot:~/notes/2020*.md.
+
    Default year
-       You can set a default year to be used for subsequent dates which  don't
-       specify  a year.  This is a line beginning with Y followed by the year.
+       You  can set a default year to be used for subsequent dates which don't
+       specify a year.  This is a line beginning with Y followed by the  year.
        Eg:
 
               Y2009  ; set default year to 2009
@@ -792,19 +825,19 @@
    Declaring commodities
        The commodity directive has several functions:
 
-       1. It declares commodities which may be used in the journal.   This  is
+       1. It  declares  commodities which may be used in the journal.  This is
           currently not enforced, but can serve as documentation.
 
-       2. It  declares what decimal mark character (period or comma) to expect
-          when parsing input - useful  to  disambiguate  international  number
-          formats  in your data.  (Without this, hledger will parse both 1,000
+       2. It declares what decimal mark character (period or comma) to  expect
+          when  parsing  input  -  useful to disambiguate international number
+          formats in your data.  (Without this, hledger will parse both  1,000
           and 1.000 as 1).
 
-       3. It declares the amount display style to use in output - decimal  and
+       3. It  declares the amount display style to use in output - decimal and
           digit group marks, number of decimal places, symbol placement etc.
 
-       You  are likely to run into one of the problems solved by commodity di-
-       rectives, sooner or later, so it's a good idea to just always use  them
+       You are likely to run into one of the problems solved by commodity  di-
+       rectives,  sooner or later, so it's a good idea to just always use them
        to declare your commodities.
 
        A commodity directive is just the word commodity followed by an amount.
@@ -817,8 +850,8 @@
               ; separating thousands with comma.
               commodity 1,000.0000 AAAA
 
-       or on multiple lines, using the "format" subdirective.  (In  this  case
-       the  commodity  symbol  appears  twice  and  should be the same in both
+       or  on  multiple lines, using the "format" subdirective.  (In this case
+       the commodity symbol appears twice and  should  be  the  same  in  both
        places.):
 
               ; commodity SYMBOL
@@ -831,9 +864,12 @@
                 format INR 1,00,00,000.00
 
        The quantity of the amount does not matter; only the format is signifi-
-       cant.   The  number  must  include a decimal mark: either a period or a
+       cant.  The number must include a decimal mark: either  a  period  or  a
        comma, followed by 0 or more decimal digits.
 
+       Note  hledger  normally  uses  banker's rounding, so 0.5 displayed with
+       zero decimal digits is "0".  (More at Amount display style.)
+
    Default commodity
        The D directive sets a default commodity, to be used for amounts  with-
        out a commodity symbol (ie, plain numbers).  This commodity will be ap-
@@ -856,7 +892,7 @@
                 a     5  ; <- commodity-less amount, parsed as $5 and displayed as $5.00
                 b
 
-   Market prices
+   Declaring market prices
        The  P directive declares a market price, which is an exchange rate be-
        tween two commodities on a certain date.  (In Ledger, they  are  called
        "historical  prices".)  These are often obtained from a stock exchange,
@@ -879,8 +915,8 @@
               P 2009/1/1 EUR $1.35
               P 2010/1/1 EUR $1.40
 
-       The -V/--value flag can be used to convert reported amounts to  another
-       commodity using these prices.
+       The -V, -X and --value flags use these market  prices  to  show  amount
+       values in another commodity.  See Valuation.
 
    Declaring accounts
        account directives can be used to pre-declare accounts.  Though not re-
@@ -1257,68 +1293,61 @@
          pression.
 
    Forecasting with periodic transactions
-       With  the --forecast flag, each periodic transaction rule generates fu-
-       ture transactions recurring at the specified interval.  These  are  not
-       saved  in  the journal, but appear in all reports.  They will look like
-       normal transactions, but with an extra tag:
-
-       o generated-transaction:~ PERIODICEXPR - shows that this was  generated
-         by a periodic transaction rule, and the period
-
-       There  is  also a hidden tag, with an underscore prefix, which does not
-       appear in hledger's output:
-
-       o _generated-transaction:~ PERIODICEXPR
+       The  --forecast  flag  activates  any periodic transaction rules in the
+       journal.  They will generate temporary  recurring  transactions,  which
+       are  not  saved  in  the  journal,  but  will appear in all reports (eg
+       print).  This can be useful for estimating balances into the future, or
+       experimenting  with  different scenarios.  Or, it can be used as a data
+       entry aid: describe recurring transactions, and every so often copy the
+       output of print --forecast into the journal.
 
-       This can be used to match transactions  generated  "just  now",  rather
-       than generated in the past and saved to the journal.
+       These  transactions  will  have  an extra tag indicating which periodic
+       rule generated them: generated-transaction:~ PERIODICEXPR.  And a simi-
+       lar,  hidden  tag  (beginning  with  an underscore) which, because it's
+       never displayed by print, can be used to match  transactions  generated
+       "just now": _generated-transaction:~ PERIODICEXPR.
 
-       Forecast  transactions  start  on  the first occurrence, and end on the
-       last occurrence, of their interval within  the  forecast  period.   The
-       forecast period:
+       Periodic  transactions  are  generated within some forecast period.  By
+       default, this
 
        o begins on the later of
 
          o the report start date if specified with -b/-p/date:
 
-         o the  day  after the latest normal (non-periodic) transaction in the
+         o the day after the latest normal (non-periodic) transaction  in  the
            journal, or today if there are no normal transactions.
 
-       o ends on the report end date if specified  with  -e/-p/date:,  or  180
-         days from today.
-
-       where  "today"  means  the current date at report time.  The "later of"
-       rule ensures that forecast transactions do not overlap normal  transac-
-       tions in time; they will begin only after normal transactions end.
-
-       Forecasting  can be useful for estimating balances into the future, and
-       experimenting with different scenarios.   Note  the  start  date  logic
-       means that forecasted transactions are automatically replaced by normal
-       transactions as you add those.
+       o ends  on  the  report  end  date  if specified with -e/-p/date:, or 6
+         months (180 days) from today.
 
-       Forecasting can also help with data entry: describe most of your trans-
-       actions  with  periodic  rules,  and  every so often copy the output of
-       print --forecast to the journal.
+       This means that periodic transactions will begin only after the  latest
+       recorded  transaction.   And a recorded transaction dated in the future
+       can prevent generation of periodic transactions.  (You can  avoid  that
+       by writing the future transaction as a one-time periodic rule instead -
+       put tilde before the date, eg ~ YYYY-MM-DD ...).
 
-       You can generate one-time transactions too: just write a period expres-
-       sion  specifying a date with no report interval.  (You could also write
-       a normal transaction with a future date,  but  remember  this  disables
-       forecast transactions on previous dates.)
+       Or, you can set your own arbitrary "forecast period", which can overlap
+       recorded  transactions,  and need not be in the future, by providing an
+       option argument, like --forecast=PERIODEXPR.  Note the equals  sign  is
+       required, a space won't work.  PERIODEXPR is a period expression, which
+       can specify the start date, end date, or both, like in a  date:  query.
+       (See  also  hledger.1  ->  Report  start  &  end date).  Some examples:
+       --forecast=202001-202004, --forecast=jan-, --forecast=2020.
 
    Budgeting with periodic transactions
-       With  the  --budget  flag,  currently supported by the balance command,
-       each periodic transaction rule declares recurring budget goals for  the
-       specified  accounts.   Eg  the  first  example above declares a goal of
-       spending $2000 on rent (and also,  a  goal  of  depositing  $2000  into
-       checking)  every  month.  Goals and actual performance can then be com-
+       With the --budget flag, currently supported  by  the  balance  command,
+       each  periodic transaction rule declares recurring budget goals for the
+       specified accounts.  Eg the first example  above  declares  a  goal  of
+       spending  $2000  on  rent  (and  also,  a goal of depositing $2000 into
+       checking) every month.  Goals and actual performance can then  be  com-
        pared in budget reports.
 
-       For more details, see: balance: Budget report and Budgeting  and  Fore-
+       For  more  details, see: balance: Budget report and Budgeting and Fore-
        casting.
 
    Auto postings
-       "Automated  postings"  or  "auto postings" are extra postings which get
-       added automatically to transactions which match  certain  queries,  de-
+       "Automated postings" or "auto postings" are extra  postings  which  get
+       added  automatically  to  transactions which match certain queries, de-
        fined by "auto posting rules", when you use the --auto flag.
 
        An auto posting rule looks a bit like a transaction:
@@ -1328,27 +1357,27 @@
                   ...
                   ACCOUNT  [AMOUNT]
 
-       except  the  first  line is an equals sign (mnemonic: = suggests match-
-       ing), followed by a query (which matches existing postings),  and  each
-       "posting"  line  describes  a  posting to be generated, and the posting
+       except the first line is an equals sign (mnemonic:  =  suggests  match-
+       ing),  followed  by a query (which matches existing postings), and each
+       "posting" line describes a posting to be  generated,  and  the  posting
        amounts can be:
 
-       o a normal amount with a commodity symbol, eg $2.  This  will  be  used
+       o a  normal  amount  with a commodity symbol, eg $2.  This will be used
          as-is.
 
        o a number, eg 2.  The commodity symbol (if any) from the matched post-
          ing will be added to this.
 
-       o a numeric multiplier, eg *2 (a star followed by  a  number  N).   The
+       o a  numeric  multiplier,  eg  *2 (a star followed by a number N).  The
          matched posting's amount (and total price, if any) will be multiplied
          by N.
 
-       o a multiplier with a commodity symbol, eg *$2 (a star, number  N,  and
+       o a  multiplier  with a commodity symbol, eg *$2 (a star, number N, and
          symbol S).  The matched posting's amount will be multiplied by N, and
          its commodity symbol will be replaced with S.
 
-       Any query term containing spaces must be enclosed in single  or  double
-       quotes,  as on the command line.  Eg, note the quotes around the second
+       Any  query  term containing spaces must be enclosed in single or double
+       quotes, as on the command line.  Eg, note the quotes around the  second
        query term below:
 
               = expenses:groceries 'expenses:dining out'
@@ -1387,24 +1416,24 @@
 
    Auto postings and multiple files
        An auto posting rule can affect any transaction in the current file, or
-       in  any  parent file or child file.  Note, currently it will not affect
+       in any parent file or child file.  Note, currently it will  not  affect
        sibling files (when multiple -f/--file are used - see #1212).
 
    Auto postings and dates
-       A posting date (or secondary date) in the matched posting,  or  (taking
-       precedence)  a  posting date in the auto posting rule itself, will also
+       A  posting  date (or secondary date) in the matched posting, or (taking
+       precedence) a posting date in the auto posting rule itself,  will  also
        be used in the generated posting.
 
    Auto postings and transaction balancing / inferred amounts / balance asser-
        tions
        Currently, auto postings are added:
 
-       o after  missing amounts are inferred, and transactions are checked for
+       o after missing amounts are inferred, and transactions are checked  for
          balancedness,
 
        o but before balance assertions are checked.
 
-       Note this means that journal entries must be balanced both  before  and
+       Note  this  means that journal entries must be balanced both before and
        after auto postings are added.  This changed in hledger 1.12+; see #893
        for background.
 
@@ -1414,11 +1443,11 @@
        o generated-posting:= QUERY - shows this was generated by an auto post-
          ing rule, and the query
 
-       o _generated-posting:=  QUERY  - a hidden tag, which does not appear in
+       o _generated-posting:= QUERY - a hidden tag, which does not  appear  in
          hledger's output.  This can be used to match postings generated "just
          now", rather than generated in the past and saved to the journal.
 
-       Also,  any transaction that has been changed by auto posting rules will
+       Also, any transaction that has been changed by auto posting rules  will
        have these tags added:
 
        o modified: - this transaction was modified
@@ -1429,7 +1458,7 @@
 
 
 REPORTING BUGS
-       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel
+       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel
        or hledger mail list)
 
 
@@ -1443,7 +1472,7 @@
 
 
 SEE ALSO
-       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),
+       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),
        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
        dot(5), ledger(1)
 
@@ -1451,4 +1480,4 @@
 
 
 
-hledger 1.17.1                    March 2020                hledger_journal(5)
+hledger 1.18                       June 2020                hledger_journal(5)
diff --git a/embeddedfiles/hledger_timeclock.5 b/embeddedfiles/hledger_timeclock.5
--- a/embeddedfiles/hledger_timeclock.5
+++ b/embeddedfiles/hledger_timeclock.5
@@ -1,5 +1,5 @@
 
-.TH "hledger_timeclock" "5" "March 2020" "hledger 1.17.1" "hledger User Manuals"
+.TH "hledger_timeclock" "5" "June 2020" "hledger 1.18" "hledger User Manuals"
 
 
 
diff --git a/embeddedfiles/hledger_timeclock.info b/embeddedfiles/hledger_timeclock.info
--- a/embeddedfiles/hledger_timeclock.info
+++ b/embeddedfiles/hledger_timeclock.info
@@ -4,8 +4,8 @@
 
 File: hledger_timeclock.info,  Node: Top,  Up: (dir)
 
-hledger_timeclock(5) hledger 1.17.1
-***********************************
+hledger_timeclock(5) hledger 1.18
+*********************************
 
 Timeclock - the time logging format of timeclock.el, as read by hledger
 
diff --git a/embeddedfiles/hledger_timeclock.txt b/embeddedfiles/hledger_timeclock.txt
--- a/embeddedfiles/hledger_timeclock.txt
+++ b/embeddedfiles/hledger_timeclock.txt
@@ -78,4 +78,4 @@
 
 
 
-hledger 1.17.1                    March 2020              hledger_timeclock(5)
+hledger 1.18                       June 2020              hledger_timeclock(5)
diff --git a/embeddedfiles/hledger_timedot.5 b/embeddedfiles/hledger_timedot.5
--- a/embeddedfiles/hledger_timedot.5
+++ b/embeddedfiles/hledger_timedot.5
@@ -1,5 +1,5 @@
 
-.TH "hledger_timedot" "5" "March 2020" "hledger 1.17.1" "hledger User Manuals"
+.TH "hledger_timedot" "5" "June 2020" "hledger 1.18" "hledger User Manuals"
 
 
 
diff --git a/embeddedfiles/hledger_timedot.info b/embeddedfiles/hledger_timedot.info
--- a/embeddedfiles/hledger_timedot.info
+++ b/embeddedfiles/hledger_timedot.info
@@ -4,8 +4,8 @@
 
 File: hledger_timedot.info,  Node: Top,  Up: (dir)
 
-hledger_timedot(5) hledger 1.17.1
-*********************************
+hledger_timedot(5) hledger 1.18
+*******************************
 
 Timedot - hledger's human-friendly time logging format
 
diff --git a/embeddedfiles/hledger_timedot.txt b/embeddedfiles/hledger_timedot.txt
--- a/embeddedfiles/hledger_timedot.txt
+++ b/embeddedfiles/hledger_timedot.txt
@@ -161,4 +161,4 @@
 
 
 
-hledger 1.17.1                    March 2020                hledger_timedot(5)
+hledger 1.18                       June 2020                hledger_timedot(5)
diff --git a/hledger.1 b/hledger.1
--- a/hledger.1
+++ b/hledger.1
@@ -1,6 +1,6 @@
 .\"t
 
-.TH "hledger" "1" "March 2020" "hledger 1.17.1.1" "hledger User Manuals"
+.TH "hledger" "1" "June 2020" "hledger 1.18" "hledger User Manuals"
 
 
 
@@ -1101,15 +1101,6 @@
 mostly in
 https://github.com/simonmichael/hledger/blob/master/hledger-lib/Hledger/Data/Types.hs.
 .IP \[bu] 2
-The JSON output from hledger commands is essentially the same as the
-JSON served by hledger-web\[aq]s JSON API, but pretty printed, using
-line breaks and indentation.
-Our pretty printer has the ability to elide data in certain cases -
-rendering non-strings as if they were strings, or displaying
-\[dq]FOO..\[dq] instead of FOO\[aq]s full details.
-This should never happen in hledger\[aq]s JSON output; if you see
-otherwise, please report as a bug.
-.IP \[bu] 2
 hledger represents quantities as Decimal values storing up to 255
 significant digits, eg for repeating decimals.
 Such numbers can arise in practice (from automatically-calculated
@@ -1136,20 +1127,28 @@
 \f[C]--alias /REGEX/=REPLACEMENT\f[R]
 .PP
 hledger\[aq]s regular expressions come from the regex-tdfa library.
-In general they:
-.IP \[bu] 2
-are case insensitive
-.IP \[bu] 2
-are infix matching (do not need to match the entire thing being matched)
-.IP \[bu] 2
-are POSIX extended regular expressions
-.IP \[bu] 2
-also support GNU word boundaries (\[rs]<, \[rs]>, \[rs]b, \[rs]B)
-.IP \[bu] 2
-and parenthesised capturing groups and numeric backreferences in
-replacement strings
-.IP \[bu] 2
-do not support mode modifiers like (?s)
+If they\[aq]re not doing what you expect, it\[aq]s important to know
+exactly what they support:
+.IP "1." 3
+they are case insensitive
+.IP "2." 3
+they are infix matching (they do not need to match the entire thing
+being matched)
+.IP "3." 3
+they are POSIX ERE (extended regular expressions)
+.IP "4." 3
+they also support GNU word boundaries (\f[C]\[rs]b\f[R],
+\f[C]\[rs]B\f[R], \f[C]\[rs]<\f[R], \f[C]\[rs]>\f[R])
+.IP "5." 3
+they do not support backreferences; if you write \f[C]\[rs]1\f[R], it
+will match the digit \f[C]1\f[R].
+Except when doing text replacement, eg in account aliases, where
+backreferences can be used in the replacement string to reference
+capturing groups in the search regexp.
+.IP "6." 3
+they do not support mode modifiers (\f[C](?s)\f[R]), character classes
+(\f[C]\[rs]w\f[R], \f[C]\[rs]d\f[R]), or anything else not mentioned
+above.
 .PP
 Some things to note:
 .IP \[bu] 2
@@ -1290,7 +1289,7 @@
 .PP
 .TS
 tab(@);
-lw(11.9n) lw(58.1n).
+lw(12.4n) lw(57.6n).
 T{
 \f[C]-b 2016/3/17\f[R]
 T}@T{
@@ -1313,16 +1312,17 @@
 all transactions in the current month
 T}
 T{
-\f[C]date:2016/3/17-\f[R]
+\f[C]date:2016/3/17..\f[R]
 T}@T{
-the above written as queries instead
+the above written as queries instead (\f[C]..\f[R] can also be replaced
+with \f[C]-\f[R])
 T}
 T{
-\f[C]date:-12/1\f[R]
+\f[C]date:..12/1\f[R]
 T}@T{
 T}
 T{
-\f[C]date:thismonth-\f[R]
+\f[C]date:thismonth..\f[R]
 T}@T{
 T}
 T{
@@ -1354,7 +1354,7 @@
 .PP
 Keywords like \[dq]from\[dq] and \[dq]to\[dq] are optional, and so are
 the spaces, as long as you don\[aq]t run two dates together.
-\[dq]to\[dq] can also be written as \[dq]-\[dq].
+\[dq]to\[dq] can also be written as \[dq]..\[dq] or \[dq]-\[dq].
 These are equivalent to the above:
 .PP
 .TS
@@ -1367,7 +1367,7 @@
 \f[C]-p2009/1/1to2009/4/1\f[R]
 T}
 T{
-\f[C]-p2009/1/1-2009/4/1\f[R]
+\f[C]-p2009/1/1..2009/4/1\f[R]
 T}
 .TE
 .PP
@@ -1594,8 +1594,7 @@
 in the account tree, down to level N.
 Use this when you want a summary with less detail.
 This flag has the same effect as a \f[C]depth:\f[R] query argument (so
-\f[C]-2\f[R], \f[C]--depth=2\f[R] or \f[C]depth:2\f[R] are basically
-equivalent).
+\f[C]-2\f[R], \f[C]--depth=2\f[R] or \f[C]depth:2\f[R] are equivalent).
 .SS Pivoting
 .PP
 Normally hledger sums amounts, and organizes them in a hierarchy, based
@@ -1671,31 +1670,48 @@
 \f[R]
 .fi
 .SS Valuation
+.PP
+hledger can show cost reports, where amounts are converted to their cost
+or sale amount at transaction time; or value reports, where amounts are
+converted to their market value in another currency/commodity at a
+specified date (using market prices inferred from your transactions, or
+declared with P directives).
+.PP
+We call this \[dq]valuation\[dq], and it is controlled by the
+\f[C]--value=VALUATIONTYPE[,COMMODITY]\f[R] option.
+It can get a little involved, so we cover all the details below.
+But most of the time, all you need to do is use these simpler flags
+instead:
+.IP \[bu] 2
+\f[C]-B\f[R] to convert to cost/sale amount, or
+.IP \[bu] 2
+\f[C]-V\f[R] to convert to market value in your base currency.
+Or occasionally,
+.IP \[bu] 2
+\f[C]-X COMMODITY\f[R] to convert to market value in some other
+currency.
 .SS -B: Cost
 .PP
-The \f[C]-B/--cost\f[R] flag converts amounts to their cost (or selling
-price) at transaction time, if they have a transaction price specified.
-This flag is equivalent to \f[C]--value=cost\f[R], described below.
-.SS -V: Market value
+The \f[C]-B/--cost\f[R] flag converts amounts to their cost or sale
+amount at transaction time, if they have a transaction price specified.
+(It is equivalent to \f[C]--value=cost\f[R].)
+.SS -V: Value
 .PP
-The \f[C]-V/--market\f[R] flag converts reported amounts to their market
-value in a default valuation commodity, using the market prices in
-effect on a default valuation date.
-For single period reports, the valuation date is today (equivalent to
-\f[C]--value=now\f[R]); for multiperiod reports, it is the last day of
-each subperiod (equivalent to \f[C]--value=end\f[R]).
+The \f[C]-V/--market\f[R] flag converts reported amounts to market value
+in their \f[I]default valuation commodity\f[R], using the market prices
+in effect on a \f[I]default valuation date\f[R].
+(More on these below.)
 .PP
 The default valuation commodity is the one referenced in the latest
 applicable market price dated on or before the valuation date.
-If most of your P declarations lead to a single home currency, this will
-usually be what you want.
-(To specify the commodity, see -X below.)
+Typically your P declarations or currency exchange transactions
+reference a single base currency, and -V will pick that.
 .PP
-Note that in hledger, market prices are always declared explicitly with
-P directives; we do not infer them from transaction prices as Ledger
-does.
+The default valuation date is today for single period reports
+(equivalent to \f[C]--value=now\f[R]), or the last day of each subperiod
+for multiperiod reports (equivalent to \f[C]--value=end\f[R]).
 .PP
-Here\[aq]s a quick example of -V:
+An example:
 .IP
 .nf
 \f[C]
@@ -1743,8 +1759,31 @@
 .PP
 The \f[C]-X/--exchange\f[R] option is like \f[C]-V\f[R], except it
 specifies the target commodity you would like to convert to.
-It is equivalent to \f[C]--value=now,COMM\f[R] or
-\f[C]--value=end,COMM\f[R].
+(It is equivalent to \f[C]--value=now,COMM\f[R] or
+\f[C]--value=end,COMM\f[R].)
+.SS Market prices
+.PP
+To convert a commodity A to commodity B, hledger looks for a suitable
+market price (exchange rate) in the following ways, in this order of
+preference:
+.IP "1." 3
+a \f[I]declared market price\f[R] - the latest P directive specifying
+the exchange rate from A to B, dated on or before the valuation date.
+.IP "2." 3
+a \f[I]transaction-implied market price\f[R] - a market price matching
+the transaction price used in the latest transaction where A is
+converted to B, dated on or before the valuation date.
+(\f[I]since hledger 1.18; experimental\f[R])
+.IP "3." 3
+a \f[I]reverse declared market price\f[R] - calculated by inverting a
+declared market price from B to A.
+.IP "4." 3
+a \f[I]reverse transaction-implied market price\f[R] - calculated by
+inverting a transaction-implied market price from B to A.
+.IP "5." 3
+an \f[I]indirect market price\f[R] - calculated by combining the
+shortest chain of market prices (any of the above types) leading from A
+to B.
 .SS --value: Flexible valuation
 .PP
 \f[I](experimental, added 201905)\f[R]
@@ -2243,9 +2282,6 @@
 \f[I]report interval\f[R]
 a flag (-D/-W/-M/-Q/-Y) or period expression that activates the
 report\[aq]s multi-period mode (whether showing one or many subperiods).
-.SS Combining -B, -V, -X, --value
-.PP
-The rightmost of these flags wins.
 .SH COMMANDS
 .PP
 hledger provides a number of subcommands; \f[C]hledger\f[R] with no
@@ -2838,13 +2874,15 @@
 \f[R]
 .fi
 .PP
-Note this is different from a normal balance report in several ways:
+This is different from a normal balance report in several ways:
 .IP \[bu] 2
 Only accounts with budget goals during the report period are shown, by
 default.
 .IP \[bu] 2
-In each column, in square brackets after the actual amount, budgeted
-amounts are shown, along with the percentage of budget used.
+In each column, in square brackets after the actual amount, budget goal
+amounts are shown, and the actual/goal percentage.
+(Note: budget goals should be in the same commodity as the actual
+amount.)
 .IP \[bu] 2
 All parent accounts are always shown, even in flat mode.
 Eg assets, assets:bank, and expenses above.
@@ -4171,7 +4209,7 @@
 .PP
 For help on these, see https://github.com/feuerbach/tasty#options
 (\f[C]-- --help\f[R] currently doesn\[aq]t show them).
-.SS Add-on Commands
+.SS Add-on commands
 .PP
 hledger also searches for external add-on commands, and will include
 these in the commands list.
@@ -4310,45 +4348,42 @@
 You may need to use \f[C]export\f[R].
 Here\[aq]s an explanation.
 .PP
-\f[B]\[dq]Illegal byte sequence\[dq] or \[dq]Invalid or incomplete
-multibyte or wide character\[dq] errors\f[R]
+\f[B]Getting errors like \[dq]Illegal byte sequence\[dq] or \[dq]Invalid
+or incomplete multibyte or wide character\[dq] or
+\[dq]commitAndReleaseBuffer: invalid argument (invalid
+character)\[dq]\f[R]
 .PD 0
 .P
 .PD
-In order to handle non-ascii letters and symbols (like \[Po]), hledger
-needs an appropriate locale.
-This is usually configured system-wide; you can also configure it
-temporarily.
-The locale may need to be one that supports UTF-8, if you built hledger
-with GHC < 7.2 (or possibly always, I\[aq]m not sure yet).
+Programs compiled with GHC (hledger, haskell build tools, etc.) need to
+have a UTF-8-aware locale configured in the environment, otherwise they
+will fail with these kinds of errors when they encounter non-ascii
+characters.
 .PP
-Here\[aq]s an example of setting the locale temporarily, on ubuntu
-gnu/linux:
+To fix it, set the LANG environment variable to some locale which
+supports UTF-8.
+The locale you choose must be installed on your system.
+.PP
+Here\[aq]s an example of setting LANG temporarily, on Ubuntu GNU/Linux:
 .IP
 .nf
 \f[C]
 $ file my.journal
-my.journal: UTF-8 Unicode text                 # <- the file is UTF8-encoded
-$ locale -a
+my.journal: UTF-8 Unicode text         # the file is UTF8-encoded
+$ echo $LANG
+C                                      # LANG is set to the default locale, which does not support UTF8
+$ locale -a                            # which locales are installed ?
 C
-en_US.utf8                             # <- a UTF8-aware locale is available
+en_US.utf8                             # here\[aq]s a UTF8-aware one we can use
 POSIX
-$ LANG=en_US.utf8 hledger -f my.journal print   # <- use it for this command
-\f[R]
-.fi
-.PP
-Here\[aq]s one way to set it permanently, there are probably better
-ways:
-.IP
-.nf
-\f[C]
-$ echo \[dq]export LANG=en_US.UTF-8\[dq] >>\[ti]/.bash_profile
-$ bash --login
+$ LANG=en_US.utf8 hledger -f my.journal print   # ensure it is used for this command
 \f[R]
 .fi
 .PP
-If we preferred to use eg \f[C]fr_FR.utf8\f[R], we might have to install
-that first:
+If available, \f[C]C.UTF-8\f[R] will also work.
+If your preferred locale isn\[aq]t listed by \f[C]locale -a\f[R], you
+might need to install it.
+Eg on Ubuntu/Debian:
 .IP
 .nf
 \f[C]
@@ -4366,9 +4401,27 @@
 \f[R]
 .fi
 .PP
-Note some platforms allow variant locale spellings, but not all (ubuntu
-accepts \f[C]fr_FR.UTF8\f[R], mac osx requires exactly
-\f[C]fr_FR.UTF-8\f[R]).
+Here\[aq]s how you could set it permanently, if you use a bash shell:
+.IP
+.nf
+\f[C]
+$ echo \[dq]export LANG=en_US.utf8\[dq] >>\[ti]/.bash_profile
+$ bash --login
+\f[R]
+.fi
+.PP
+Exact spelling and capitalisation may be important.
+Note the difference on MacOS (\f[C]UTF-8\f[R], not \f[C]utf8\f[R]).
+Some platforms (eg ubuntu) allow variant spellings, but others (eg
+macos) require it to be exact:
+.IP
+.nf
+\f[C]
+$ locale -a | grep -iE en_us.*utf
+en_US.UTF-8
+$ LANG=en_US.UTF-8 hledger -f my.journal print
+\f[R]
+.fi
 
 
 .SH "REPORTING BUGS"
diff --git a/hledger.cabal b/hledger.cabal
--- a/hledger.cabal
+++ b/hledger.cabal
@@ -1,24 +1,24 @@
 cabal-version: 1.12
 
--- This file has been generated from package.yaml by hpack version 0.31.2.
+-- This file has been generated from package.yaml by hpack version 0.33.0.
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: 517c77ccc2198cfbde2bd9ddbf73f74f2f551f4fadd429d591d50e567bf65564
+-- hash: 7c3d5511ae3e0b87af5d89a1f2b127fb9c33cacb05894148d9169c77a6309362
 
 name:           hledger
-version:        1.17.1.1
-synopsis:       Command-line interface for the hledger accounting tool
-description:    This is hledger's command-line interface.
+version:        1.18
+synopsis:       Command-line interface for the hledger accounting system
+description:    The command-line interface for the hledger accounting system.
                 Its basic function is to read a plain text file describing
                 financial transactions and produce useful reports.
                 .
-                hledger is a cross-platform program for tracking money, time, or
-                any other commodity, using double-entry accounting and a simple,
-                editable file format. It is inspired by and largely compatible
-                with ledger(1).  hledger provides command-line, terminal and web
-                interfaces, and aims to be a reliable, practical tool for daily
-                use.
+                hledger is a robust, cross-platform set of tools for tracking money,
+                time, or any other commodity, using double-entry accounting and a
+                simple, editable file format, with command-line, terminal and web
+                interfaces. It is a Haskell rewrite of Ledger, and one of the leading
+                implementations of Plain Text Accounting. Read more at:
+                <https://hledger.org>
 category:       Finance, Console
 stability:      stable
 homepage:       http://hledger.org
@@ -27,7 +27,7 @@
 maintainer:     Simon Michael <simon@joyful.com>
 license:        GPL-3
 license-file:   LICENSE
-tested-with:    GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.5, GHC==8.8.2, GHC==8.10
+tested-with:    GHC==8.0.2, GHC==8.2.2, GHC==8.4.4, GHC==8.6.5, GHC==8.8.3, GHC==8.10.0.20200123
 build-type:     Simple
 extra-source-files:
     CHANGES.md
@@ -144,7 +144,7 @@
   other-modules:
       Paths_hledger
   ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans -optP-Wno-nonportable-include-path
-  cpp-options: -DVERSION="1.17.1.1"
+  cpp-options: -DVERSION="1.18"
   build-depends:
       Decimal >=0.5.1
     , Diff
@@ -161,7 +161,7 @@
     , filepath
     , hashable >=1.2.4
     , haskeline >=0.6
-    , hledger-lib >=1.17.1 && <1.18
+    , hledger-lib >=1.18 && <1.19
     , lucid
     , math-functions >=0.3.3.0
     , megaparsec >=7.0.0 && <8.1
@@ -197,7 +197,7 @@
   hs-source-dirs:
       app
   ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans -optP-Wno-nonportable-include-path
-  cpp-options: -DVERSION="1.17.1.1"
+  cpp-options: -DVERSION="1.18"
   build-depends:
       Decimal >=0.5.1
     , aeson
@@ -213,7 +213,7 @@
     , filepath
     , haskeline >=0.6
     , hledger
-    , hledger-lib >=1.17.1 && <1.18
+    , hledger-lib >=1.18 && <1.19
     , math-functions >=0.3.3.0
     , megaparsec >=7.0.0 && <8.1
     , mtl >=2.2.1
@@ -249,7 +249,7 @@
   hs-source-dirs:
       test
   ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans -optP-Wno-nonportable-include-path
-  cpp-options: -DVERSION="1.17.1.1"
+  cpp-options: -DVERSION="1.18"
   build-depends:
       Decimal >=0.5.1
     , aeson
@@ -265,7 +265,7 @@
     , filepath
     , haskeline >=0.6
     , hledger
-    , hledger-lib >=1.17.1 && <1.18
+    , hledger-lib >=1.18 && <1.19
     , math-functions >=0.3.3.0
     , megaparsec >=7.0.0 && <8.1
     , mtl >=2.2.1
@@ -315,7 +315,7 @@
     , filepath
     , haskeline >=0.6
     , hledger
-    , hledger-lib >=1.17.1 && <1.18
+    , hledger-lib >=1.18 && <1.19
     , html
     , math-functions >=0.3.3.0
     , megaparsec >=7.0.0 && <8.1
diff --git a/hledger.info b/hledger.info
--- a/hledger.info
+++ b/hledger.info
@@ -3,8 +3,8 @@
 
 File: hledger.info,  Node: Top,  Next: COMMON TASKS,  Up: (dir)
 
-hledger(1) hledger 1.17.1.1
-***************************
+hledger(1) hledger 1.18
+***********************
 
 hledger - a command-line accounting tool
 
@@ -1021,14 +1021,6 @@
      JSON, read the Haskell type definitions, which are mostly in
      https://github.com/simonmichael/hledger/blob/master/hledger-lib/Hledger/Data/Types.hs.
 
-   * The JSON output from hledger commands is essentially the same as
-     the JSON served by hledger-web's JSON API, but pretty printed,
-     using line breaks and indentation.  Our pretty printer has the
-     ability to elide data in certain cases - rendering non-strings as
-     if they were strings, or displaying "FOO.." instead of FOO's full
-     details.  This should never happen in hledger's JSON output; if you
-     see otherwise, please report as a bug.
-
    * hledger represents quantities as Decimal values storing up to 255
      significant digits, eg for repeating decimals.  Such numbers can
      arise in practice (from automatically-calculated transaction
@@ -1052,17 +1044,22 @@
    * account alias directives and options: 'alias /REGEX/ =
      REPLACEMENT', '--alias /REGEX/=REPLACEMENT'
 
-   hledger's regular expressions come from the regex-tdfa library.  In
-general they:
+   hledger's regular expressions come from the regex-tdfa library.  If
+they're not doing what you expect, it's important to know exactly what
+they support:
 
-   * are case insensitive
-   * are infix matching (do not need to match the entire thing being
-     matched)
-   * are POSIX extended regular expressions
-   * also support GNU word boundaries (\<, \>, \b, \B)
-   * and parenthesised capturing groups and numeric backreferences in
-     replacement strings
-   * do not support mode modifiers like (?s)
+  1. they are case insensitive
+  2. they are infix matching (they do not need to match the entire thing
+     being matched)
+  3. they are POSIX ERE (extended regular expressions)
+  4. they also support GNU word boundaries ('\b', '\B', '\<', '\>')
+  5. they do not support backreferences; if you write '\1', it will
+     match the digit '1'.  Except when doing text replacement, eg in
+     account aliases, where backreferences can be used in the
+     replacement string to reference capturing groups in the search
+     regexp.
+  6. they do not support mode modifiers ('(?s)'), character classes
+     ('\w', '\d'), or anything else not mentioned above.
 
    Some things to note:
 
@@ -1146,17 +1143,18 @@
 
    Examples:
 
-'-b          begin on St. Patrick's day 2016
+'-b           begin on St. Patrick's day 2016
 2016/3/17'
-'-e 12/1'    end at the start of december 1st of the current year
-             (11/30 will be the last date included)
-'-b          all transactions on or after the 1st of the current month
+'-e 12/1'     end at the start of december 1st of the current year
+              (11/30 will be the last date included)
+'-b           all transactions on or after the 1st of the current month
 thismonth'
-'-p          all transactions in the current month
+'-p           all transactions in the current month
 thismonth'
-'date:2016/3/17-'the above written as queries instead
-'date:-12/1'
-'date:thismonth-'
+'date:2016/3/17..'the above written as queries instead ('..' can also be
+              replaced with '-')
+'date:..12/1'
+'date:thismonth..'
 'date:thismonth'
 
 
@@ -1189,11 +1187,11 @@
 
    Keywords like "from" and "to" are optional, and so are the spaces, as
 long as you don't run two dates together.  "to" can also be written as
-"-".  These are equivalent to the above:
+".."  or "-".  These are equivalent to the above:
 
 '-p "2009/1/1 2009/4/1"'
 '-p2009/1/1to2009/4/1'
-'-p2009/1/1-2009/4/1'
+'-p2009/1/1..2009/4/1'
 
    Dates are smart dates, so if the current year is 2009, the above can
 also be written as:
@@ -1300,7 +1298,7 @@
 balance and register will show only the uppermost accounts in the
 account tree, down to level N. Use this when you want a summary with
 less detail.  This flag has the same effect as a 'depth:' query argument
-(so '-2', '--depth=2' or 'depth:2' are basically equivalent).
+(so '-2', '--depth=2' or 'depth:2' are equivalent).
 
 
 File: hledger.info,  Node: Pivoting,  Next: Valuation,  Prev: Depth limiting,  Up: OPTIONS
@@ -1365,47 +1363,61 @@
 2.17 Valuation
 ==============
 
+hledger can show cost reports, where amounts are converted to their cost
+or sale amount at transaction time; or value reports, where amounts are
+converted to their market value in another currency/commodity at a
+specified date (using market prices inferred from your transactions, or
+declared with P directives).
+
+   We call this "valuation", and it is controlled by the
+'--value=VALUATIONTYPE[,COMMODITY]' option.  It can get a little
+involved, so we cover all the details below.  But most of the time, all
+you need to do is use these simpler flags instead:
+
+   * '-B' to convert to cost/sale amount, or
+   * '-V' to convert to market value in your base currency.  Or
+     occasionally,
+   * '-X COMMODITY' to convert to market value in some other currency.
+
 * Menu:
 
 * -B Cost::
-* -V Market value::
+* -V Value::
 * -X Market value in specified commodity::
+* Market prices::
 * --value Flexible valuation::
 * Effect of --value on reports::
-* Combining -B -V -X --value::
 
 
-File: hledger.info,  Node: -B Cost,  Next: -V Market value,  Up: Valuation
+File: hledger.info,  Node: -B Cost,  Next: -V Value,  Up: Valuation
 
 2.17.1 -B: Cost
 ---------------
 
-The '-B/--cost' flag converts amounts to their cost (or selling price)
-at transaction time, if they have a transaction price specified.  This
-flag is equivalent to '--value=cost', described below.
+The '-B/--cost' flag converts amounts to their cost or sale amount at
+transaction time, if they have a transaction price specified.  (It is
+equivalent to '--value=cost'.)
 
 
-File: hledger.info,  Node: -V Market value,  Next: -X Market value in specified commodity,  Prev: -B Cost,  Up: Valuation
+File: hledger.info,  Node: -V Value,  Next: -X Market value in specified commodity,  Prev: -B Cost,  Up: Valuation
 
-2.17.2 -V: Market value
------------------------
+2.17.2 -V: Value
+----------------
 
-The '-V/--market' flag converts reported amounts to their market value
-in a default valuation commodity, using the market prices in effect on a
-default valuation date.  For single period reports, the valuation date
-is today (equivalent to '--value=now'); for multiperiod reports, it is
-the last day of each subperiod (equivalent to '--value=end').
+The '-V/--market' flag converts reported amounts to market value in
+their _default valuation commodity_, using the market prices in effect
+on a _default valuation date_.  (More on these below.)
 
    The default valuation commodity is the one referenced in the latest
-applicable market price dated on or before the valuation date.  If most
-of your P declarations lead to a single home currency, this will usually
-be what you want.  (To specify the commodity, see -X below.)
+applicable market price dated on or before the valuation date.
+Typically your P declarations or currency exchange transactions
+reference a single base currency, and -V will pick that.
 
-   Note that in hledger, market prices are always declared explicitly
-with P directives; we do not infer them from transaction prices as
-Ledger does.
+   The default valuation date is today for single period reports
+(equivalent to '--value=now'), or the last day of each subperiod for
+multiperiod reports (equivalent to '--value=end').
 
-   Here's a quick example of -V:
+   An example:
 
 ; one euro is worth this many dollars from nov 1
 P 2016/11/01 € $1.10
@@ -1435,19 +1447,47 @@
              $103.00  assets:euros
 
 
-File: hledger.info,  Node: -X Market value in specified commodity,  Next: --value Flexible valuation,  Prev: -V Market value,  Up: Valuation
+File: hledger.info,  Node: -X Market value in specified commodity,  Next: Market prices,  Prev: -V Value,  Up: Valuation
 
 2.17.3 -X: Market value in specified commodity
 ----------------------------------------------
 
 The '-X/--exchange' option is like '-V', except it specifies the target
-commodity you would like to convert to.  It is equivalent to
-'--value=now,COMM' or '--value=end,COMM'.
+commodity you would like to convert to.  (It is equivalent to
+'--value=now,COMM' or '--value=end,COMM'.)
 
 
-File: hledger.info,  Node: --value Flexible valuation,  Next: Effect of --value on reports,  Prev: -X Market value in specified commodity,  Up: Valuation
+File: hledger.info,  Node: Market prices,  Next: --value Flexible valuation,  Prev: -X Market value in specified commodity,  Up: Valuation
 
-2.17.4 -value: Flexible valuation
+2.17.4 Market prices
+--------------------
+
+To convert a commodity A to commodity B, hledger looks for a suitable
+market price (exchange rate) in the following ways, in this order of
+preference:
+
+  1. a _declared market price_ - the latest P directive specifying the
+     exchange rate from A to B, dated on or before the valuation date.
+
+  2. a _transaction-implied market price_ - a market price matching the
+     transaction price used in the latest transaction where A is
+     converted to B, dated on or before the valuation date.  (_since
+     hledger 1.18; experimental_)
+
+  3. a _reverse declared market price_ - calculated by inverting a
+     declared market price from B to A.
+
+  4. a _reverse transaction-implied market price_ - calculated by
+     inverting a transaction-implied market price from B to A.
+
+  5. an _indirect market price_ - calculated by combining the shortest
+     chain of market prices (any of the above types) leading from A to
+     B.
+
+
+File: hledger.info,  Node: --value Flexible valuation,  Next: Effect of --value on reports,  Prev: Market prices,  Up: Valuation
+
+2.17.5 -value: Flexible valuation
 ---------------------------------
 
 _(experimental, added 201905)_
@@ -1617,9 +1657,9 @@
     b          -0.50A
 
 
-File: hledger.info,  Node: Effect of --value on reports,  Next: Combining -B -V -X --value,  Prev: --value Flexible valuation,  Up: Valuation
+File: hledger.info,  Node: Effect of --value on reports,  Prev: --value Flexible valuation,  Up: Valuation
 
-2.17.5 Effect of -value on reports
+2.17.6 Effect of -value on reports
 ----------------------------------
 
 Here is a reference for how '--value' currently affects each part of
@@ -1733,14 +1773,6 @@
      subperiods).
 
 
-File: hledger.info,  Node: Combining -B -V -X --value,  Prev: Effect of --value on reports,  Up: Valuation
-
-2.17.6 Combining -B, -V, -X, -value
------------------------------------
-
-The rightmost of these flags wins.
-
-
 File: hledger.info,  Node: COMMANDS,  Next: ENVIRONMENT,  Prev: OPTIONS,  Up: Top
 
 3 COMMANDS
@@ -1793,7 +1825,7 @@
 * stats::
 * tags::
 * test::
-* Add-on Commands::
+* Add-on commands::
 
 
 File: hledger.info,  Node: accounts,  Next: activity,  Up: COMMANDS
@@ -2319,14 +2351,14 @@
 ----------------------++----------------------------------------------------
                       ||      0 [              0]       0 [              0] 
 
-   Note this is different from a normal balance report in several ways:
+   This is different from a normal balance report in several ways:
 
    * Only accounts with budget goals during the report period are shown,
      by default.
 
-   * In each column, in square brackets after the actual amount,
-     budgeted amounts are shown, along with the percentage of budget
-     used.
+   * In each column, in square brackets after the actual amount, budget
+     goal amounts are shown, and the actual/goal percentage.  (Note:
+     budget goals should be in the same commodity as the actual amount.)
 
    * All parent accounts are always shown, even in flat mode.  Eg
      assets, assets:bank, and expenses above.
@@ -3494,7 +3526,7 @@
 instead.
 
 
-File: hledger.info,  Node: test,  Next: Add-on Commands,  Prev: tags,  Up: COMMANDS
+File: hledger.info,  Node: test,  Next: Add-on commands,  Prev: tags,  Up: COMMANDS
 
 3.29 test
 =========
@@ -3521,9 +3553,9 @@
 ('-- --help' currently doesn't show them).
 
 
-File: hledger.info,  Node: Add-on Commands,  Prev: test,  Up: COMMANDS
+File: hledger.info,  Node: Add-on commands,  Prev: test,  Up: COMMANDS
 
-3.30 Add-on Commands
+3.30 Add-on commands
 ====================
 
 hledger also searches for external add-on commands, and will include
@@ -3562,7 +3594,7 @@
 * interest::
 
 
-File: hledger.info,  Node: ui,  Next: web,  Up: Add-on Commands
+File: hledger.info,  Node: ui,  Next: web,  Up: Add-on commands
 
 3.30.1 ui
 ---------
@@ -3570,7 +3602,7 @@
 hledger-ui provides an efficient terminal interface.
 
 
-File: hledger.info,  Node: web,  Next: iadd,  Prev: ui,  Up: Add-on Commands
+File: hledger.info,  Node: web,  Next: iadd,  Prev: ui,  Up: Add-on commands
 
 3.30.2 web
 ----------
@@ -3580,7 +3612,7 @@
    Third party add-ons, maintained separately from hledger, include:
 
 
-File: hledger.info,  Node: iadd,  Next: interest,  Prev: web,  Up: Add-on Commands
+File: hledger.info,  Node: iadd,  Next: interest,  Prev: web,  Up: Add-on commands
 
 3.30.3 iadd
 -----------
@@ -3589,7 +3621,7 @@
 command.
 
 
-File: hledger.info,  Node: interest,  Prev: iadd,  Up: Add-on Commands
+File: hledger.info,  Node: interest,  Prev: iadd,  Up: Add-on commands
 
 3.30.4 interest
 ---------------
@@ -3689,32 +3721,32 @@
 variable.  The command 'env | grep LEDGER_FILE' should show it.  You may
 need to use 'export'.  Here's an explanation.
 
-   *"Illegal byte sequence" or "Invalid or incomplete multibyte or wide
-character" errors*
-In order to handle non-ascii letters and symbols (like £), hledger needs
-an appropriate locale.  This is usually configured system-wide; you can
-also configure it temporarily.  The locale may need to be one that
-supports UTF-8, if you built hledger with GHC < 7.2 (or possibly always,
-I'm not sure yet).
+   *Getting errors like "Illegal byte sequence" or "Invalid or
+incomplete multibyte or wide character" or "commitAndReleaseBuffer:
+invalid argument (invalid character)"*
+Programs compiled with GHC (hledger, haskell build tools, etc.)  need to
+have a UTF-8-aware locale configured in the environment, otherwise they
+will fail with these kinds of errors when they encounter non-ascii
+characters.
 
-   Here's an example of setting the locale temporarily, on ubuntu
-gnu/linux:
+   To fix it, set the LANG environment variable to some locale which
+supports UTF-8.  The locale you choose must be installed on your system.
 
+   Here's an example of setting LANG temporarily, on Ubuntu GNU/Linux:
+
 $ file my.journal
-my.journal: UTF-8 Unicode text                 # <- the file is UTF8-encoded
-$ locale -a
+my.journal: UTF-8 Unicode text         # the file is UTF8-encoded
+$ echo $LANG
+C                                      # LANG is set to the default locale, which does not support UTF8
+$ locale -a                            # which locales are installed ?
 C
-en_US.utf8                             # <- a UTF8-aware locale is available
+en_US.utf8                             # here's a UTF8-aware one we can use
 POSIX
-$ LANG=en_US.utf8 hledger -f my.journal print   # <- use it for this command
-
-   Here's one way to set it permanently, there are probably better ways:
-
-$ echo "export LANG=en_US.UTF-8" >>~/.bash_profile
-$ bash --login
+$ LANG=en_US.utf8 hledger -f my.journal print   # ensure it is used for this command
 
-   If we preferred to use eg 'fr_FR.utf8', we might have to install that
-first:
+   If available, 'C.UTF-8' will also work.  If your preferred locale
+isn't listed by 'locale -a', you might need to install it.  Eg on
+Ubuntu/Debian:
 
 $ apt-get install language-pack-fr
 $ locale -a
@@ -3728,193 +3760,203 @@
 POSIX
 $ LANG=fr_FR.utf8 hledger -f my.journal print
 
-   Note some platforms allow variant locale spellings, but not all
-(ubuntu accepts 'fr_FR.UTF8', mac osx requires exactly 'fr_FR.UTF-8').
+   Here's how you could set it permanently, if you use a bash shell:
 
+$ echo "export LANG=en_US.utf8" >>~/.bash_profile
+$ bash --login
+
+   Exact spelling and capitalisation may be important.  Note the
+difference on MacOS ('UTF-8', not 'utf8').  Some platforms (eg ubuntu)
+allow variant spellings, but others (eg macos) require it to be exact:
+
+$ locale -a | grep -iE en_us.*utf
+en_US.UTF-8
+$ LANG=en_US.UTF-8 hledger -f my.journal print
+
 
 Tag Table:
 Node: Top68
-Node: COMMON TASKS2323
-Ref: #common-tasks2435
-Node: Getting help2842
-Ref: #getting-help2974
-Node: Constructing command lines3527
-Ref: #constructing-command-lines3719
-Node: Starting a journal file4416
-Ref: #starting-a-journal-file4614
-Node: Setting opening balances5802
-Ref: #setting-opening-balances5998
-Node: Recording transactions9139
-Ref: #recording-transactions9319
-Node: Reconciling9875
-Ref: #reconciling10018
-Node: Reporting12275
-Ref: #reporting12415
-Node: Migrating to a new file16414
-Ref: #migrating-to-a-new-file16562
-Node: OPTIONS16861
-Ref: #options16968
-Node: General options17338
-Ref: #general-options17463
-Node: Command options20233
-Ref: #command-options20384
-Node: Command arguments20782
-Ref: #command-arguments20929
-Node: Queries21809
-Ref: #queries21964
-Node: Special characters in arguments and queries25926
-Ref: #special-characters-in-arguments-and-queries26154
-Node: More escaping26605
-Ref: #more-escaping26767
-Node: Even more escaping27063
-Ref: #even-more-escaping27257
-Node: Less escaping27928
-Ref: #less-escaping28090
-Node: Unicode characters28335
-Ref: #unicode-characters28517
-Node: Input files29929
-Ref: #input-files30072
-Node: Output destination32001
-Ref: #output-destination32153
-Node: Output format32578
-Ref: #output-format32728
-Node: Regular expressions34776
-Ref: #regular-expressions34933
-Node: Smart dates36294
-Ref: #smart-dates36445
-Node: Report start & end date37806
-Ref: #report-start-end-date37978
-Node: Report intervals39416
-Ref: #report-intervals39581
-Node: Period expressions39971
-Ref: #period-expressions40131
-Node: Depth limiting44257
-Ref: #depth-limiting44401
-Node: Pivoting44743
-Ref: #pivoting44866
-Node: Valuation46542
-Ref: #valuation46644
-Node: -B Cost46824
-Ref: #b-cost46935
-Node: -V Market value47133
-Ref: #v-market-value47307
-Node: -X Market value in specified commodity48739
-Ref: #x-market-value-in-specified-commodity48978
-Node: --value Flexible valuation49154
-Ref: #value-flexible-valuation49380
-Node: Effect of --value on reports53885
-Ref: #effect-of---value-on-reports54101
-Node: Combining -B -V -X --value59647
-Ref: #combining--b--v--x---value59830
-Node: COMMANDS59866
-Ref: #commands59974
-Node: accounts61058
-Ref: #accounts61156
-Node: activity61855
-Ref: #activity61965
-Node: add62348
-Ref: #add62447
-Node: balance65186
-Ref: #balance65297
-Node: Classic balance report66755
-Ref: #classic-balance-report66928
-Node: Customising the classic balance report68297
-Ref: #customising-the-classic-balance-report68525
-Node: Colour support70601
-Ref: #colour-support70768
-Node: Flat mode70941
-Ref: #flat-mode71089
-Node: Depth limited balance reports71502
-Ref: #depth-limited-balance-reports71687
-Node: Percentages72143
-Ref: #percentages72309
-Node: Multicolumn balance report73446
-Ref: #multicolumn-balance-report73626
-Node: Budget report78888
-Ref: #budget-report79031
-Node: Nested budgets84233
-Ref: #nested-budgets84345
-Ref: #output-format-187826
-Node: balancesheet88023
-Ref: #balancesheet88159
-Node: balancesheetequity89625
-Ref: #balancesheetequity89774
-Node: cashflow90497
-Ref: #cashflow90625
-Node: check-dates91804
-Ref: #check-dates91931
-Node: check-dupes92210
-Ref: #check-dupes92334
-Node: close92627
-Ref: #close92741
-Node: close usage94263
-Ref: #close-usage94356
-Node: commodities97169
-Ref: #commodities97296
-Node: descriptions97378
-Ref: #descriptions97506
-Node: diff97687
-Ref: #diff97793
-Node: files98840
-Ref: #files98940
-Node: help99087
-Ref: #help99187
-Node: import100268
-Ref: #import100382
-Node: Importing balance assignments101275
-Ref: #importing-balance-assignments101423
-Node: incomestatement102072
-Ref: #incomestatement102205
-Node: notes103692
-Ref: #notes103805
-Node: payees103931
-Ref: #payees104037
-Node: prices104195
-Ref: #prices104301
-Node: print104642
-Ref: #print104752
-Node: print-unique109538
-Ref: #print-unique109664
-Node: register109949
-Ref: #register110076
-Node: Custom register output114248
-Ref: #custom-register-output114377
-Node: register-match115714
-Ref: #register-match115848
-Node: rewrite116199
-Ref: #rewrite116314
-Node: Re-write rules in a file118169
-Ref: #re-write-rules-in-a-file118303
-Node: Diff output format119513
-Ref: #diff-output-format119682
-Node: rewrite vs print --auto120774
-Ref: #rewrite-vs.-print---auto120953
-Node: roi121509
-Ref: #roi121607
-Node: stats122619
-Ref: #stats122718
-Node: tags123506
-Ref: #tags123604
-Node: test123898
-Ref: #test124006
-Node: Add-on Commands124753
-Ref: #add-on-commands124870
-Node: ui126213
-Ref: #ui126301
-Node: web126355
-Ref: #web126458
-Node: iadd126574
-Ref: #iadd126685
-Node: interest126767
-Ref: #interest126874
-Node: ENVIRONMENT127114
-Ref: #environment127226
-Node: FILES128055
-Ref: #files-1128158
-Node: LIMITATIONS128371
-Ref: #limitations128490
-Node: TROUBLESHOOTING129232
-Ref: #troubleshooting129345
+Node: COMMON TASKS2315
+Ref: #common-tasks2427
+Node: Getting help2834
+Ref: #getting-help2966
+Node: Constructing command lines3519
+Ref: #constructing-command-lines3711
+Node: Starting a journal file4408
+Ref: #starting-a-journal-file4606
+Node: Setting opening balances5794
+Ref: #setting-opening-balances5990
+Node: Recording transactions9131
+Ref: #recording-transactions9311
+Node: Reconciling9867
+Ref: #reconciling10010
+Node: Reporting12267
+Ref: #reporting12407
+Node: Migrating to a new file16406
+Ref: #migrating-to-a-new-file16554
+Node: OPTIONS16853
+Ref: #options16960
+Node: General options17330
+Ref: #general-options17455
+Node: Command options20225
+Ref: #command-options20376
+Node: Command arguments20774
+Ref: #command-arguments20921
+Node: Queries21801
+Ref: #queries21956
+Node: Special characters in arguments and queries25918
+Ref: #special-characters-in-arguments-and-queries26146
+Node: More escaping26597
+Ref: #more-escaping26759
+Node: Even more escaping27055
+Ref: #even-more-escaping27249
+Node: Less escaping27920
+Ref: #less-escaping28082
+Node: Unicode characters28327
+Ref: #unicode-characters28509
+Node: Input files29921
+Ref: #input-files30064
+Node: Output destination31993
+Ref: #output-destination32145
+Node: Output format32570
+Ref: #output-format32720
+Node: Regular expressions34302
+Ref: #regular-expressions34459
+Node: Smart dates36195
+Ref: #smart-dates36346
+Node: Report start & end date37707
+Ref: #report-start-end-date37879
+Node: Report intervals39376
+Ref: #report-intervals39541
+Node: Period expressions39931
+Ref: #period-expressions40091
+Node: Depth limiting44227
+Ref: #depth-limiting44371
+Node: Pivoting44703
+Ref: #pivoting44826
+Node: Valuation46502
+Ref: #valuation46604
+Node: -B Cost47524
+Ref: #b-cost47628
+Node: -V Value47800
+Ref: #v-value47953
+Node: -X Market value in specified commodity49226
+Ref: #x-market-value-in-specified-commodity49445
+Node: Market prices49623
+Ref: #market-prices49808
+Node: --value Flexible valuation50733
+Ref: #value-flexible-valuation50934
+Node: Effect of --value on reports55439
+Ref: #effect-of---value-on-reports55620
+Node: COMMANDS61166
+Ref: #commands61274
+Node: accounts62358
+Ref: #accounts62456
+Node: activity63155
+Ref: #activity63265
+Node: add63648
+Ref: #add63747
+Node: balance66486
+Ref: #balance66597
+Node: Classic balance report68055
+Ref: #classic-balance-report68228
+Node: Customising the classic balance report69597
+Ref: #customising-the-classic-balance-report69825
+Node: Colour support71901
+Ref: #colour-support72068
+Node: Flat mode72241
+Ref: #flat-mode72389
+Node: Depth limited balance reports72802
+Ref: #depth-limited-balance-reports72987
+Node: Percentages73443
+Ref: #percentages73609
+Node: Multicolumn balance report74746
+Ref: #multicolumn-balance-report74926
+Node: Budget report80188
+Ref: #budget-report80331
+Node: Nested budgets85597
+Ref: #nested-budgets85709
+Ref: #output-format-189190
+Node: balancesheet89387
+Ref: #balancesheet89523
+Node: balancesheetequity90989
+Ref: #balancesheetequity91138
+Node: cashflow91861
+Ref: #cashflow91989
+Node: check-dates93168
+Ref: #check-dates93295
+Node: check-dupes93574
+Ref: #check-dupes93698
+Node: close93991
+Ref: #close94105
+Node: close usage95627
+Ref: #close-usage95720
+Node: commodities98533
+Ref: #commodities98660
+Node: descriptions98742
+Ref: #descriptions98870
+Node: diff99051
+Ref: #diff99157
+Node: files100204
+Ref: #files100304
+Node: help100451
+Ref: #help100551
+Node: import101632
+Ref: #import101746
+Node: Importing balance assignments102639
+Ref: #importing-balance-assignments102787
+Node: incomestatement103436
+Ref: #incomestatement103569
+Node: notes105056
+Ref: #notes105169
+Node: payees105295
+Ref: #payees105401
+Node: prices105559
+Ref: #prices105665
+Node: print106006
+Ref: #print106116
+Node: print-unique110902
+Ref: #print-unique111028
+Node: register111313
+Ref: #register111440
+Node: Custom register output115612
+Ref: #custom-register-output115741
+Node: register-match117078
+Ref: #register-match117212
+Node: rewrite117563
+Ref: #rewrite117678
+Node: Re-write rules in a file119533
+Ref: #re-write-rules-in-a-file119667
+Node: Diff output format120877
+Ref: #diff-output-format121046
+Node: rewrite vs print --auto122138
+Ref: #rewrite-vs.-print---auto122317
+Node: roi122873
+Ref: #roi122971
+Node: stats123983
+Ref: #stats124082
+Node: tags124870
+Ref: #tags124968
+Node: test125262
+Ref: #test125370
+Node: Add-on commands126117
+Ref: #add-on-commands126234
+Node: ui127577
+Ref: #ui127665
+Node: web127719
+Ref: #web127822
+Node: iadd127938
+Ref: #iadd128049
+Node: interest128131
+Ref: #interest128238
+Node: ENVIRONMENT128478
+Ref: #environment128590
+Node: FILES129419
+Ref: #files-1129522
+Node: LIMITATIONS129735
+Ref: #limitations129854
+Node: TROUBLESHOOTING130596
+Ref: #troubleshooting130709
 
 End Tag Table
 
diff --git a/hledger.txt b/hledger.txt
--- a/hledger.txt
+++ b/hledger.txt
@@ -868,14 +868,6 @@
          https://github.com/simonmichael/hledger/blob/master/hledger-
          lib/Hledger/Data/Types.hs.
 
-       o The JSON output from hledger commands is essentially the same as  the
-         JSON served by hledger-web's JSON API, but pretty printed, using line
-         breaks and indentation.  Our pretty printer has the ability to  elide
-         data  in  certain  cases  -  rendering  non-strings  as  if they were
-         strings, or displaying "FOO.." instead of FOO's full  details.   This
-         should  never  happen in hledger's JSON output; if you see otherwise,
-         please report as a bug.
-
        o hledger represents quantities as Decimal values  storing  up  to  255
          significant  digits,  eg  for  repeating  decimals.  Such numbers can
          arise in practice (from automatically-calculated transaction prices),
@@ -896,22 +888,26 @@
        o account alias directives and options: alias  /REGEX/  =  REPLACEMENT,
          --alias /REGEX/=REPLACEMENT
 
-       hledger's  regular  expressions  come  from the regex-tdfa library.  In
-       general they:
+       hledger's  regular  expressions  come  from the regex-tdfa library.  If
+       they're not doing what you expect, it's important to know exactly  what
+       they support:
 
-       o are case insensitive
+       1. they are case insensitive
 
-       o are infix matching (do not need  to  match  the  entire  thing  being
-         matched)
+       2. they  are infix matching (they do not need to match the entire thing
+          being matched)
 
-       o are POSIX extended regular expressions
+       3. they are POSIX ERE (extended regular expressions)
 
-       o also support GNU word boundaries (\<, \>, \b, \B)
+       4. they also support GNU word boundaries (\b, \B, \<, \>)
 
-       o and  parenthesised capturing groups and numeric backreferences in re-
-         placement strings
+       5. they do not support backreferences; if you write \1, it  will  match
+          the  digit  1.   Except  when  doing text replacement, eg in account
+          aliases, where backreferences can be used in the replacement  string
+          to reference capturing groups in the search regexp.
 
-       o do not support mode modifiers like (?s)
+       6. they  do  not  support mode modifiers ((?s)), character classes (\w,
+          \d), or anything else not mentioned above.
 
        Some things to note:
 
@@ -938,6 +934,7 @@
        2004/10/1,   2004-01-01,   exact date, several separators allowed.   Year
        2004.9.1                   is 4+ digits, month is 1-12, day is 1-31
        2004                       start of year
+
        2004/10                    start of month
        10/1                       month and day in current year
        21                         day in current month
@@ -986,43 +983,44 @@
 
        Examples:
 
-       -b 2016/3/17      begin on St. Patrick's day 2016
-       -e 12/1           end at the start of  december  1st  of  the  current  year
-                         (11/30 will be the last date included)
-       -b thismonth      all transactions on or after the 1st of the current month
-       -p thismonth      all transactions in the current month
-       date:2016/3/17-   the above written as queries instead
-       date:-12/1
-       date:thismonth-
+       -b 2016/3/17       begin on St. Patrick's day 2016
+       -e 12/1            end at the start of  december  1st  of  the  current  year
+                          (11/30 will be the last date included)
+       -b thismonth       all transactions on or after the 1st of the current month
+       -p thismonth       all transactions in the current month
+       date:2016/3/17..   the above written as queries instead (.. can also  be  re-
+                          placed with -)
+       date:..12/1
+       date:thismonth..
        date:thismonth
 
    Report intervals
        A report interval can be specified so that commands like register, bal-
-       ance  and  activity will divide their reports into multiple subperiods.
-       The  basic  intervals  can  be  selected  with   one   of   -D/--daily,
-       -W/--weekly,  -M/--monthly,  -Q/--quarterly, or -Y/--yearly.  More com-
-       plex intervals may be specified with a period expression.   Report  in-
+       ance and activity will divide their reports into  multiple  subperiods.
+       The   basic   intervals   can  be  selected  with  one  of  -D/--daily,
+       -W/--weekly, -M/--monthly, -Q/--quarterly, or -Y/--yearly.   More  com-
+       plex  intervals  may be specified with a period expression.  Report in-
        tervals can not be specified with a query.
 
    Period expressions
-       The  -p/--period  option accepts period expressions, a shorthand way of
+       The -p/--period option accepts period expressions, a shorthand  way  of
        expressing a start date, end date, and/or report interval all at once.
 
-       Here's a basic period expression specifying the first quarter of  2009.
-       Note,  hledger  always treats start dates as inclusive and end dates as
+       Here's  a basic period expression specifying the first quarter of 2009.
+       Note, hledger always treats start dates as inclusive and end  dates  as
        exclusive:
 
        -p "from 2009/1/1 to 2009/4/1"
 
-       Keywords like "from" and "to" are optional, and so are the  spaces,  as
-       long  as you don't run two dates together.  "to" can also be written as
-       "-".  These are equivalent to the above:
+       Keywords  like  "from" and "to" are optional, and so are the spaces, as
+       long as you don't run two dates together.  "to" can also be written  as
+       ".." or "-".  These are equivalent to the above:
 
        -p "2009/1/1 2009/4/1"
        -p2009/1/1to2009/4/1
-       -p2009/1/1-2009/4/1
+       -p2009/1/1..2009/4/1
 
-       Dates are smart dates, so if the current year is 2009,  the  above  can
+       Dates  are  smart  dates, so if the current year is 2009, the above can
        also be written as:
 
        -p "1/1 4/1"
@@ -1036,64 +1034,62 @@
                             1, 2009
        -p "from 2009/1"     the same
        -p "from 2009"       the same
-       -p "to 2009"         everything  before january
+       -p "to 2009"         everything before  january
                             1, 2009
 
-       A single date with no "from" or "to" defines both  the  start  and  end
+       A  single  date  with  no "from" or "to" defines both the start and end
        date like so:
 
-       -p "2009"       the  year 2009; equivalent
+       -p "2009"       the year 2009;  equivalent
                        to "2009/1/1 to 2010/1/1"
-       -p "2009/1"     the month of jan;  equiva-
+       -p "2009/1"     the  month of jan; equiva-
                        lent   to   "2009/1/1   to
                        2009/2/1"
-       -p "2009/1/1"   just that day;  equivalent
+       -p "2009/1/1"   just  that day; equivalent
                        to "2009/1/1 to 2009/1/2"
 
-       The  argument  of  -p can also begin with, or be, a report interval ex-
+       The argument of -p can also begin with, or be, a  report  interval  ex-
        pression.  The basic report intervals are daily, weekly, monthly, quar-
-       terly,  or yearly, which have the same effect as the -D,-W,-M,-Q, or -Y
-       flags.  Between report interval and start/end dates (if any), the  word
+       terly, or yearly, which have the same effect as the -D,-W,-M,-Q, or  -Y
+       flags.   Between report interval and start/end dates (if any), the word
        in is optional.  Examples:
 
        -p "weekly from 2009/1/1 to 2009/4/1"
        -p "monthly in 2008"
        -p "quarterly"
 
-       Note  that  weekly, monthly, quarterly and yearly intervals will always
+       Note that weekly, monthly, quarterly and yearly intervals  will  always
        start on the first day on week, month, quarter or year accordingly, and
-       will  end on the last day of same period, even if associated period ex-
+       will end on the last day of same period, even if associated period  ex-
        pression specifies different explicit start and end date.
 
        For example:
 
-       -p "weekly from  2009/1/1   starts on 2008/12/29, closest preceding Mon-
+       -p  "weekly from 2009/1/1   starts on 2008/12/29, closest preceding Mon-
        to 2009/4/1"                day
-
-
-       -p      "monthly       in   starts on 2018/11/01
+       -p       "monthly      in   starts on 2018/11/01
        2008/11/25"
-       -p     "quarterly    from   starts on 2009/04/01,  ends  on  2009/06/30,
+       -p    "quarterly     from   starts  on  2009/04/01,  ends on 2009/06/30,
        2009-05-05 to 2009-06-01"   which are first and last days of Q2 2009
        -p      "yearly      from   starts on 2009/01/01, first day of 2009
        2009-12-29"
 
-       The following more complex report intervals  are  also  supported:  bi-
+       The  following  more  complex  report intervals are also supported: bi-
        weekly,   bimonthly,   every   day|week|month|quarter|year,   every   N
        days|weeks|months|quarters|years.
 
-       All of these will start on the first day of the  requested  period  and
+       All  of  these  will start on the first day of the requested period and
        end on the last one, as described above.
 
        Examples:
 
-       -p "bimonthly from 2008"    periods  will have boundaries on 2008/01/01,
+       -p "bimonthly from 2008"    periods will have boundaries on  2008/01/01,
                                    2008/03/01, ...
        -p "every 2 weeks"          starts on closest preceding Monday
-       -p "every  5  month  from   periods  will have boundaries on 2009/03/01,
+       -p  "every  5  month from   periods will have boundaries on  2009/03/01,
        2009/03"                    2009/08/01, ...
 
-       If you want intervals that start on arbitrary day of your choosing  and
+       If  you want intervals that start on arbitrary day of your choosing and
        span a week, month or year, you need to use any of the following:
 
        every Nth day of week, every <weekday>, every Nth day [of month], every
@@ -1105,42 +1101,42 @@
        -p  "every  2nd  day  of   periods will go from Tue to Tue
        week"
        -p "every Tue"             same
-       -p "every 15th day"        period boundaries will  be  on  15th  of  each
+       -p "every 15th day"        period  boundaries  will  be  on  15th of each
                                   month
-       -p "every 2nd Monday"      period  boundaries will be on second Monday of
+       -p "every 2nd Monday"      period boundaries will be on second Monday  of
                                   each month
        -p "every 11/05"           yearly periods with boundaries on 5th of Nov
        -p "every 5th Nov"         same
        -p "every Nov 5th"         same
 
-       Show historical balances at end of 15th each month (N is exclusive  end
+       Show  historical balances at end of 15th each month (N is exclusive end
        date):
 
        hledger balance -H -p "every 16th day"
 
-       Group  postings  from  start  of wednesday to end of next tuesday (N is
+       Group postings from start of wednesday to end of  next  tuesday  (N  is
        start date and exclusive end date):
 
        hledger register checking -p "every 3rd day of week"
 
    Depth limiting
        With the --depth N option (short form: -N), commands like account, bal-
-       ance  and register will show only the uppermost accounts in the account
-       tree, down to level N.  Use this when you want a summary with less  de-
+       ance and register will show only the uppermost accounts in the  account
+       tree,  down to level N.  Use this when you want a summary with less de-
        tail.  This flag has the same effect as a depth: query argument (so -2,
-       --depth=2 or depth:2 are basically equivalent).
+       --depth=2 or depth:2 are equivalent).
 
    Pivoting
        Normally hledger sums amounts, and organizes them in a hierarchy, based
-       on  account  name.  The --pivot FIELD option causes it to sum and orga-
-       nize hierarchy based on the value of some other field  instead.   FIELD
+       on account name.  The --pivot FIELD option causes it to sum  and  orga-
+       nize  hierarchy  based on the value of some other field instead.  FIELD
        can be: code, description, payee, note, or the full name (case insensi-
        tive) of any tag.  As with account names, values containing colon:sepa-
        rated:parts will be displayed hierarchically in reports.
 
-       --pivot  is  a  general  option affecting all reports; you can think of
+       --pivot is a general option affecting all reports;  you  can  think  of
        hledger transforming the journal before any other processing, replacing
-       every  posting's  account name with the value of the specified field on
+       every posting's account name with the value of the specified  field  on
        that posting, inheriting it from the transaction or using a blank value
        if it's not present.
 
@@ -1166,7 +1162,7 @@
               --------------------
                                  0
 
-       One  way  to show only amounts with a member: value (using a query, de-
+       One way to show only amounts with a member: value (using a  query,  de-
        scribed below):
 
               $ hledger balance --pivot member tag:member=.
@@ -1174,7 +1170,7 @@
               --------------------
                             -2 EUR
 
-       Another way (the acct:  query  matches  against  the  pivoted  "account
+       Another  way  (the  acct:  query  matches  against the pivoted "account
        name"):
 
               $ hledger balance --pivot member acct:.
@@ -1183,28 +1179,44 @@
                             -2 EUR
 
    Valuation
+       hledger can show cost reports, where amounts  are  converted  to  their
+       cost  or  sale  amount  at  transaction  time;  or value reports, where
+       amounts are converted to their market value in another currency/commod-
+       ity  at a specified date (using market prices inferred from your trans-
+       actions, or declared with P directives).
+
+       We call this "valuation", and it is controlled  by  the  --value=VALUA-
+       TIONTYPE[,COMMODITY] option.  It can get a little involved, so we cover
+       all the details below.  But most of the time, all you need to do is use
+       these simpler flags instead:
+
+       o -B to convert to cost/sale amount, or
+
+       o -V  to  convert  to market value in your base currency.  Or occasion-
+         ally,
+
+       o -X COMMODITY to convert to market value in some other currency.
+
    -B: Cost
-       The -B/--cost flag converts amounts to their cost (or selling price) at
-       transaction time, if they have a  transaction  price  specified.   This
-       flag is equivalent to --value=cost, described below.
+       The -B/--cost flag converts amounts to their cost  or  sale  amount  at
+       transaction  time,  if they have a transaction price specified.  (It is
+       equivalent to --value=cost.)
 
-   -V: Market value
-       The -V/--market flag converts reported amounts to their market value in
-       a default valuation commodity, using the market prices in effect  on  a
-       default  valuation date.  For single period reports, the valuation date
-       is today (equivalent to --value=now); for multiperiod  reports,  it  is
-       the last day of each subperiod (equivalent to --value=end).
+   -V: Value
+       The -V/--market flag converts reported amounts to market value in their
+       default valuation commodity, using the market prices in effect on a de-
+       fault valuation date.  (More on these below.)
 
        The default valuation commodity is the one referenced in the latest ap-
-       plicable market price dated on or before the valuation date.   If  most
-       of  your  P declarations lead to a single home currency, this will usu-
-       ally be what you want.  (To specify the commodity, see -X below.)
+       plicable market price dated on or before the valuation date.  Typically
+       your P declarations or currency exchange transactions reference a  sin-
+       gle base currency, and -V will pick that.
 
-       Note that in hledger, market prices are always declared explicitly with
-       P  directives;  we  do not infer them from transaction prices as Ledger
-       does.
+       The  default valuation date is today for single period reports (equiva-
+       lent to --value=now), or the last day of each subperiod for multiperiod
+       reports (equivalent to --value=end).
 
-       Here's a quick example of -V:
+       An example:
 
               ; one euro is worth this many dollars from nov 1
               P 2016/11/01 EUR $1.10
@@ -1227,17 +1239,39 @@
               $ hledger -f t.j bal -N euros -V -e 2016/11/4
                            $110.00  assets:euros
 
-       What are they worth after 2016/12/21 ?  (no report end date  specified,
+       What  are they worth after 2016/12/21 ?  (no report end date specified,
        defaults to today)
 
               $ hledger -f t.j bal -N euros -V
                            $103.00  assets:euros
 
    -X: Market value in specified commodity
-       The  -X/--exchange  option  is  like -V, except it specifies the target
-       commodity  you  would  like  to  convert  to.   It  is  equivalent   to
-       --value=now,COMM or --value=end,COMM.
+       The -X/--exchange option is like -V, except  it  specifies  the  target
+       commodity  you  would  like  to  convert  to.   (It  is  equivalent  to
+       --value=now,COMM or --value=end,COMM.)
 
+   Market prices
+       To convert a commodity A to commodity B, hledger looks for  a  suitable
+       market  price  (exchange  rate) in the following ways, in this order of
+       preference:
+
+       1. a declared market price - the latest P directive specifying the  ex-
+          change rate from A to B, dated on or before the valuation date.
+
+       2. a  transaction-implied  market  price  - a market price matching the
+          transaction price used in the latest transaction  where  A  is  con-
+          verted  to B, dated on or before the valuation date.  (since hledger
+          1.18; experimental)
+
+       3. a reverse declared market price - calculated by inverting a declared
+          market price from B to A.
+
+       4. a reverse transaction-implied market price - calculated by inverting
+          a transaction-implied market price from B to A.
+
+       5. an indirect market price -  calculated  by  combining  the  shortest
+          chain of market prices (any of the above types) leading from A to B.
+
    --value: Flexible valuation
        (experimental, added 201905)
 
@@ -1414,7 +1448,6 @@
        Report type    -B,            -V, -X         --value=then    --value=end    --value=DATE,
                       --value=cost                                                 --value=now
        ------------------------------------------------------------------------------------------
-
        print
        posting        cost           value at re-   value      at   value at re-   value      at
        amounts                       port end  or   posting date    port      or   DATE/today
@@ -1459,6 +1492,9 @@
        (with report   postings be-   fore  report                   fore  report   report start
        interval and   fore  report   start                          start
        -H)            start
+
+
+
        budget         like    bal-   like    bal-   not supported   like    bal-   like balances
        amounts with   ances          ances                          ances
        --budget
@@ -1508,9 +1544,6 @@
               report's multi-period mode (whether showing one or many subperi-
               ods).
 
-   Combining -B, -V, -X, --value
-       The rightmost of these flags wins.
-
 COMMANDS
        hledger  provides  a  number  of subcommands; hledger with no arguments
        shows a list.
@@ -1995,27 +2028,28 @@
               ----------------------++----------------------------------------------------
                                     ||      0 [              0]       0 [              0]
 
-       Note this is different from a normal balance report in several ways:
+       This is different from a normal balance report in several ways:
 
        o Only  accounts  with budget goals during the report period are shown,
          by default.
 
-       o In each column, in square brackets after the actual amount,  budgeted
-         amounts are shown, along with the percentage of budget used.
+       o In each column, in square brackets after the  actual  amount,  budget
+         goal  amounts are shown, and the actual/goal percentage.  (Note: bud-
+         get goals should be in the same commodity as the actual amount.)
 
-       o All  parent accounts are always shown, even in flat mode.  Eg assets,
+       o All parent accounts are always shown, even in flat mode.  Eg  assets,
          assets:bank, and expenses above.
 
-       o Amounts always include all subaccounts, budgeted or unbudgeted,  even
+       o Amounts  always include all subaccounts, budgeted or unbudgeted, even
          in flat mode.
 
        This means that the numbers displayed will not always add up! Eg above,
-       the expenses actual amount includes the  gifts  and  supplies  transac-
-       tions,  but  the  expenses:gifts and expenses:supplies accounts are not
+       the  expenses  actual  amount  includes the gifts and supplies transac-
+       tions, but the expenses:gifts and expenses:supplies  accounts  are  not
        shown, as they have no budget amounts declared.
 
-       This can be confusing.  When you need to make things clearer,  use  the
-       -E/--empty  flag,  which  will reveal all accounts including unbudgeted
+       This  can  be confusing.  When you need to make things clearer, use the
+       -E/--empty flag, which will reveal all  accounts  including  unbudgeted
        ones, giving the full picture.  Eg:
 
               $ hledger balance -M --budget --empty
@@ -2057,12 +2091,12 @@
        For more examples, see Budgeting and Forecasting.
 
    Nested budgets
-       You can add budgets to any account in your account hierarchy.   If  you
+       You  can  add budgets to any account in your account hierarchy.  If you
        have budgets on both parent account and some of its children, then bud-
-       get(s) of the child account(s) would be added to the  budget  of  their
+       get(s)  of  the  child account(s) would be added to the budget of their
        parent, much like account balances behave.
 
-       In  the  most  simple case this means that once you add a budget to any
+       In the most simple case this means that once you add a  budget  to  any
        account, all its parents would have budget as well.
 
        To illustrate this, consider the following budget:
@@ -2072,13 +2106,13 @@
                   expenses:personal:electronics    $100.00
                   liabilities
 
-       With this, monthly budget for electronics is defined  to  be  $100  and
-       budget  for  personal expenses is an additional $1000, which implicitly
+       With  this,  monthly  budget  for electronics is defined to be $100 and
+       budget for personal expenses is an additional $1000,  which  implicitly
        means that budget for both expenses:personal and expenses is $1100.
 
-       Transactions in expenses:personal:electronics will be counted both  to-
+       Transactions  in expenses:personal:electronics will be counted both to-
        wards its $100 budget and $1100 of expenses:personal , and transactions
-       in any other subaccount of expenses:personal would be  counted  towards
+       in  any  other subaccount of expenses:personal would be counted towards
        only towards the budget of expenses:personal.
 
        For example, let's consider these transactions:
@@ -2104,9 +2138,9 @@
                   expenses:personal          $30.00
                   liabilities
 
-       As  you  can  see,  we have transactions in expenses:personal:electron-
-       ics:upgrades and expenses:personal:train tickets,  and  since  both  of
-       these  accounts  are  without explicitly defined budget, these transac-
+       As you can see, we  have  transactions  in  expenses:personal:electron-
+       ics:upgrades  and  expenses:personal:train  tickets,  and since both of
+       these accounts are without explicitly defined  budget,  these  transac-
        tions would be counted towards budgets of expenses:personal:electronics
        and expenses:personal accordingly:
 
@@ -2122,7 +2156,7 @@
               -------------------------------++-------------------------------
                                              ||        0 [                 0]
 
-       And  with --empty, we can get a better picture of budget allocation and
+       And with --empty, we can get a better picture of budget allocation  and
        consumption:
 
               $ hledger balance --budget -M --empty
@@ -2141,17 +2175,17 @@
 
    Output format
        This command also supports the output destination and output format op-
-       tions  The output formats supported are txt, csv, (multicolumn non-bud-
+       tions The output formats supported are txt, csv, (multicolumn  non-bud-
        get reports only) html, and (experimental) json.
 
    balancesheet
        balancesheet, bs
        This command displays a simple balance sheet, showing historical ending
-       balances  of  asset  and  liability accounts (ignoring any report begin
-       date).  It assumes that these accounts are under a top-level  asset  or
+       balances of asset and liability accounts  (ignoring  any  report  begin
+       date).   It  assumes that these accounts are under a top-level asset or
        liability account (case insensitive, plural forms also allowed).
 
-       Note  this  report shows all account balances with normal positive sign
+       Note this report shows all account balances with normal  positive  sign
        (like conventional financial statements, unlike balance/print/register)
        (experimental).
 
@@ -2177,21 +2211,21 @@
                                  0
 
        With a reporting interval, multiple columns will be shown, one for each
-       report period.  As with multicolumn balance reports, you can alter  the
-       report  mode  with  --change/--cumulative/--historical.   Normally bal-
-       ancesheet shows historical ending balances, which is what you need  for
-       a  balance  sheet;  note  this means it ignores report begin dates (and
-       -T/--row-total, since summing end  balances  generally  does  not  make
-       sense).   Instead  of absolute values percentages can be displayed with
+       report  period.  As with multicolumn balance reports, you can alter the
+       report mode  with  --change/--cumulative/--historical.   Normally  bal-
+       ancesheet  shows historical ending balances, which is what you need for
+       a balance sheet; note this means it ignores  report  begin  dates  (and
+       -T/--row-total,  since  summing  end  balances  generally does not make
+       sense).  Instead of absolute values percentages can be  displayed  with
        -%.
 
        This command also supports the output destination and output format op-
-       tions  The output formats supported are txt, csv, html, and (experimen-
+       tions The output formats supported are txt, csv, html, and  (experimen-
        tal) json.
 
    balancesheetequity
        balancesheetequity, bse
-       Just like balancesheet, but also reports Equity (which  it  assumes  is
+       Just  like  balancesheet,  but also reports Equity (which it assumes is
        under a top-level equity account).
 
        Example:
@@ -2221,15 +2255,15 @@
                                  0
 
        This command also supports the output destination and output format op-
-       tions The output formats supported are txt, csv, html, and  (experimen-
+       tions  The output formats supported are txt, csv, html, and (experimen-
        tal) json.
 
    cashflow
        cashflow, cf
-       This  command  displays a simple cashflow statement, showing changes in
-       "cash" accounts.  It assumes that these accounts are under a  top-level
-       asset  account (case insensitive, plural forms also allowed) and do not
-       contain receivable or A/R in their name.  Note this  report  shows  all
+       This command displays a simple cashflow statement, showing  changes  in
+       "cash"  accounts.  It assumes that these accounts are under a top-level
+       asset account (case insensitive, plural forms also allowed) and do  not
+       contain  receivable  or  A/R in their name.  Note this report shows all
        account balances with normal positive sign (like conventional financial
        statements, unlike balance/print/register) (experimental).
 
@@ -2250,90 +2284,90 @@
                                $-1
 
        With a reporting interval, multiple columns will be shown, one for each
-       report  period.   Normally cashflow shows changes in assets per period,
-       though as with multicolumn balance reports you  can  alter  the  report
+       report period.  Normally cashflow shows changes in assets  per  period,
+       though  as  with  multicolumn  balance reports you can alter the report
        mode with --change/--cumulative/--historical.  Instead of absolute val-
        ues percentages can be displayed with -%.
 
        This command also supports the output destination and output format op-
-       tions  The output formats supported are txt, csv, html, and (experimen-
+       tions The output formats supported are txt, csv, html, and  (experimen-
        tal) json.
 
    check-dates
        check-dates
-       Check that transactions are sorted by increasing date.   With  --date2,
-       checks  secondary  dates  instead.   With  --strict, dates must also be
-       unique.  With a query, only matched transactions'  dates  are  checked.
+       Check  that  transactions are sorted by increasing date.  With --date2,
+       checks secondary dates instead.  With  --strict,  dates  must  also  be
+       unique.   With  a  query, only matched transactions' dates are checked.
        Reads the default journal file, or another specified with -f.
 
    check-dupes
        check-dupes
-       Reports  account names having the same leaf but different prefixes.  In
-       other words, two or  more  leaves  that  are  categorized  differently.
+       Reports account names having the same leaf but different prefixes.   In
+       other  words,  two  or  more  leaves  that are categorized differently.
        Reads the default journal file, or another specified as an argument.
 
        An example: http://stefanorodighiero.net/software/hledger-dupes.html
 
    close
        close, equity
-       Prints  a  "closing  balances"  transaction  and  an "opening balances"
+       Prints a "closing  balances"  transaction  and  an  "opening  balances"
        transaction that bring account balances to and from zero, respectively.
        These can be added to your journal file(s), eg to bring asset/liability
-       balances forward into a new journal file, or to close out  revenues/ex-
+       balances  forward into a new journal file, or to close out revenues/ex-
        penses to retained earnings at the end of a period.
 
-       You  can  print  just one of these transactions by using the --close or
-       --open flag.  You can customise their descriptions  with  the  --close-
+       You can print just one of these transactions by using  the  --close  or
+       --open  flag.   You  can customise their descriptions with the --close-
        desc and --open-desc options.
 
        One amountless posting to "equity:opening/closing balances" is added to
-       balance the transactions, by default.  You can customise  this  account
-       name  with  --close-acct  and  --open-acct;  if you specify only one of
+       balance  the  transactions, by default.  You can customise this account
+       name with --close-acct and --open-acct; if  you  specify  only  one  of
        these, it will be used for both.
 
        With --x/--explicit, the equity posting's amount will be shown.  And if
-       it  involves multiple commodities, a posting for each commodity will be
+       it involves multiple commodities, a posting for each commodity will  be
        shown, as with the print command.
 
-       With --interleaved, the equity postings are shown next to the  postings
+       With  --interleaved, the equity postings are shown next to the postings
        they balance, which makes troubleshooting easier.
 
        By default, transaction prices in the journal are ignored when generat-
        ing the closing/opening transactions.  With --show-costs, this cost in-
-       formation  is preserved (balance -B reports will be unchanged after the
-       transition).  Separate postings are generated for  each  cost  in  each
-       commodity.   Note  this can generate very large journal entries, if you
+       formation is preserved (balance -B reports will be unchanged after  the
+       transition).   Separate  postings  are  generated for each cost in each
+       commodity.  Note this can generate very large journal entries,  if  you
        have many foreign currency or investment transactions.
 
    close usage
        If you split your journal files by time (eg yearly), you will typically
-       run  this command at the end of the year, and save the closing transac-
-       tion as last entry of the old file, and the opening transaction as  the
-       first  entry  of the new file.  This makes the files self contained, so
-       that correct balances are reported no matter which of them are  loaded.
-       Ie,  if you load just one file, the balances are initialised correctly;
-       or if you load several files, the  redundant  closing/opening  transac-
-       tions  cancel  each other out.  (They will show up in print or register
-       reports; you can  exclude  them  with  a  query  like  not:desc:'(open-
+       run this command at the end of the year, and save the closing  transac-
+       tion  as last entry of the old file, and the opening transaction as the
+       first entry of the new file.  This makes the files self  contained,  so
+       that  correct balances are reported no matter which of them are loaded.
+       Ie, if you load just one file, the balances are initialised  correctly;
+       or  if  you  load several files, the redundant closing/opening transac-
+       tions cancel each other out.  (They will show up in print  or  register
+       reports;  you  can  exclude  them  with  a  query like not:desc:'(open-
        ing|closing) balances'.)
 
        If you're running a business, you might also use this command to "close
-       the books" at the end of  an  accounting  period,  transferring  income
-       statement  account  balances  to  retained  earnings.  (You may want to
+       the  books"  at  the  end  of an accounting period, transferring income
+       statement account balances to retained  earnings.   (You  may  want  to
        change the equity account name to something like "equity:retained earn-
        ings".)
 
-       By  default,  the  closing transaction is dated yesterday, the balances
-       are calculated as of end of yesterday, and the opening  transaction  is
-       dated  today.  To close on some other date, use: hledger close -e OPEN-
-       INGDATE.  Eg, to close/open on the 2018/2019  boundary,  use  -e  2019.
+       By default, the closing transaction is dated  yesterday,  the  balances
+       are  calculated  as of end of yesterday, and the opening transaction is
+       dated today.  To close on some other date, use: hledger close -e  OPEN-
+       INGDATE.   Eg,  to  close/open  on the 2018/2019 boundary, use -e 2019.
        You can also use -p or date:PERIOD (any starting date is ignored).
 
-       Both  transactions  will  include balance assertions for the closed/re-
+       Both transactions will include balance assertions  for  the  closed/re-
        opened accounts.  You probably shouldn't use status or realness filters
-       (like  -C or -R or status:) with this command, or the generated balance
-       assertions will depend on these flags.  Likewise, if you run this  com-
-       mand  with  --auto, the balance assertions will probably always require
+       (like -C or -R or status:) with this command, or the generated  balance
+       assertions  will depend on these flags.  Likewise, if you run this com-
+       mand with --auto, the balance assertions will probably  always  require
        --auto.
 
        Examples:
@@ -2388,18 +2422,18 @@
 
    diff
        diff
-       Compares  a  particular  account's transactions in two input files.  It
+       Compares a particular account's transactions in two  input  files.   It
        shows any transactions to this account which are in one file but not in
        the other.
 
        More precisely, for each posting affecting this account in either file,
-       it looks for a corresponding posting in the other file which posts  the
-       same  amount  to  the  same  account (ignoring date, description, etc.)
+       it  looks for a corresponding posting in the other file which posts the
+       same amount to the same  account  (ignoring  date,  description,  etc.)
        Since postings not transactions are compared, this also works when mul-
        tiple bank transactions have been combined into a single journal entry.
 
        This is useful eg if you have downloaded an account's transactions from
-       your bank (eg as CSV data).  When hledger and your bank disagree  about
+       your  bank (eg as CSV data).  When hledger and your bank disagree about
        the account balance, you can compare the bank data with your journal to
        find out the cause.
 
@@ -2417,20 +2451,20 @@
 
    files
        files
-       List all files included in the journal.  With a  REGEX  argument,  only
+       List  all  files  included in the journal.  With a REGEX argument, only
        file names matching the regular expression (case sensitive) are shown.
 
    help
        help
        Show any of the hledger manuals.
 
-       The  help  command  displays any of the main hledger manuals, in one of
-       several ways.  Run it with no argument to list the manuals, or  provide
+       The help command displays any of the main hledger manuals,  in  one  of
+       several  ways.  Run it with no argument to list the manuals, or provide
        a full or partial manual name to select one.
 
-       hledger  manuals  are  available in several formats.  hledger help will
-       use the first of these  display  methods  that  it  finds:  info,  man,
-       $PAGER,  less,  stdout (or when non-interactive, just stdout).  You can
+       hledger manuals are available in several formats.   hledger  help  will
+       use  the  first  of  these  display  methods  that it finds: info, man,
+       $PAGER, less, stdout (or when non-interactive, just stdout).   You  can
        force a particular viewer with the --info, --man, --pager, --cat flags.
 
        Examples:
@@ -2457,9 +2491,9 @@
 
    import
        import
-       Read new transactions added to each FILE since last run, and  add  them
-       to  the  main journal file.  Or with --dry-run, just print the transac-
-       tions that would be added.  Or with --catchup, just  mark  all  of  the
+       Read  new  transactions added to each FILE since last run, and add them
+       to the main journal file.  Or with --dry-run, just print  the  transac-
+       tions  that  would  be  added.  Or with --catchup, just mark all of the
        FILEs' transactions as imported, without actually importing any.
 
        The input files are specified as arguments - no need to write -f before
@@ -2470,36 +2504,36 @@
        ing transactions are always added to the input files in increasing date
        order, and by saving .latest.FILE state files.
 
-       The  --dry-run output is in journal format, so you can filter it, eg to
+       The --dry-run output is in journal format, so you can filter it, eg  to
        see only uncategorised transactions:
 
               $ hledger import --dry ... | hledger -f- print unknown --ignore-assertions
 
    Importing balance assignments
-       Entries added by import will have their posting amounts  made  explicit
-       (like  hledger  print  -x).  This means that any balance assignments in
-       imported files must be evaluated; but, imported files don't get to  see
-       the  main file's account balances.  As a result, importing entries with
+       Entries  added  by import will have their posting amounts made explicit
+       (like hledger print -x).  This means that any  balance  assignments  in
+       imported  files must be evaluated; but, imported files don't get to see
+       the main file's account balances.  As a result, importing entries  with
        balance assignments (eg from an institution that provides only balances
-       and  not  posting  amounts)  will  probably  generate incorrect posting
+       and not posting  amounts)  will  probably  generate  incorrect  posting
        amounts.  To avoid this problem, use print instead of import:
 
               $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE
 
-       (If you think import should leave amounts  implicit  like  print  does,
+       (If  you  think  import  should leave amounts implicit like print does,
        please test it and send a pull request.)
 
    incomestatement
        incomestatement, is
-       This  command  displays a simple income statement, showing revenues and
-       expenses during a period.  It assumes that these accounts are  under  a
-       top-level  revenue or income or expense account (case insensitive, plu-
-       ral forms also allowed).  Note this report shows all  account  balances
-       with  normal positive sign (like conventional financial statements, un-
+       This command displays a simple income statement, showing  revenues  and
+       expenses  during  a period.  It assumes that these accounts are under a
+       top-level revenue or income or expense account (case insensitive,  plu-
+       ral  forms  also allowed).  Note this report shows all account balances
+       with normal positive sign (like conventional financial statements,  un-
        like balance/print/register) (experimental).
 
-       This command displays a simple income statement.  It currently  assumes
-       that  you have top-level accounts named income (or revenue) and expense
+       This  command displays a simple income statement.  It currently assumes
+       that you have top-level accounts named income (or revenue) and  expense
        (plural forms also allowed.)
 
               $ hledger incomestatement
@@ -2524,13 +2558,13 @@
                                  0
 
        With a reporting interval, multiple columns will be shown, one for each
-       report  period.   Normally  incomestatement shows revenues/expenses per
-       period, though as with multicolumn balance reports you  can  alter  the
-       report  mode with --change/--cumulative/--historical.  Instead of abso-
+       report period.  Normally incomestatement  shows  revenues/expenses  per
+       period,  though  as  with multicolumn balance reports you can alter the
+       report mode with --change/--cumulative/--historical.  Instead of  abso-
        lute values percentages can be displayed with -%.
 
        This command also supports the output destination and output format op-
-       tions  The output formats supported are txt, csv, html, and (experimen-
+       tions The output formats supported are txt, csv, html, and  (experimen-
        tal) json.
 
    notes
@@ -2558,10 +2592,10 @@
 
    prices
        prices
-       Print market price directives from the  journal.   With  --costs,  also
-       print  synthetic market prices based on transaction prices.  With --in-
-       verted-costs, also print inverse prices based  on  transaction  prices.
-       Prices  (and  postings  providing  prices)  can be filtered by a query.
+       Print  market  price  directives  from the journal.  With --costs, also
+       print synthetic market prices based on transaction prices.  With  --in-
+       verted-costs,  also  print  inverse prices based on transaction prices.
+       Prices (and postings providing prices) can  be  filtered  by  a  query.
        Price amounts are always displayed with their full precision.
 
    print
@@ -2569,11 +2603,11 @@
        Show transaction journal entries, sorted by date.
 
        The print command displays full journal entries (transactions) from the
-       journal  file  in date order, tidily formatted.  With --date2, transac-
+       journal file in date order, tidily formatted.  With  --date2,  transac-
        tions are sorted by secondary date instead.
 
        print's output is always a valid hledger journal.
-       It preserves all transaction information, but it does not preserve  di-
+       It  preserves all transaction information, but it does not preserve di-
        rectives or inter-transaction comments
 
               $ hledger print
@@ -2600,43 +2634,43 @@
 
        Normally, the journal entry's explicit or implicit amount style is pre-
        served.  For example, when an amount is omitted in the journal, it will
-       not  appear  in the output.  Similarly, when a transaction price is im-
-       plied but not written, it will not appear in the output.  You  can  use
-       the  -x/--explicit  flag to make all amounts and transaction prices ex-
-       plicit, which can be useful for  troubleshooting  or  for  making  your
+       not appear in the output.  Similarly, when a transaction price  is  im-
+       plied  but  not written, it will not appear in the output.  You can use
+       the -x/--explicit flag to make all amounts and transaction  prices  ex-
+       plicit,  which  can  be  useful  for troubleshooting or for making your
        journal more readable and robust against data entry errors.  -x is also
        implied by using any of -B,-V,-X,--value.
 
-       Note, -x/--explicit will cause postings with a  multi-commodity  amount
-       (these  can  arise  when  a multi-commodity transaction has an implicit
-       amount) to be split into multiple  single-commodity  postings,  keeping
+       Note,  -x/--explicit  will cause postings with a multi-commodity amount
+       (these can arise when a multi-commodity  transaction  has  an  implicit
+       amount)  to  be  split into multiple single-commodity postings, keeping
        the output parseable.
 
-       With  -B/--cost,  amounts with transaction prices are converted to cost
+       With -B/--cost, amounts with transaction prices are converted  to  cost
        using that price.  This can be used for troubleshooting.
 
-       With -m/--match and a STR argument, print will show at most one  trans-
-       action:  the  one  one whose description is most similar to STR, and is
-       most recent.  STR should contain at least two characters.  If there  is
+       With  -m/--match and a STR argument, print will show at most one trans-
+       action: the one one whose description is most similar to  STR,  and  is
+       most  recent.  STR should contain at least two characters.  If there is
        no similar-enough match, no transaction will be shown.
 
        With --new, for each FILE being read, hledger reads (and writes) a spe-
-       cial state file (.latest.FILE in the same  directory),  containing  the
-       latest  transaction  date(s)  that  were  seen last time FILE was read.
-       When this file is found, only transactions with newer  dates  (and  new
-       transactions  on  the latest date) are printed.  This is useful for ig-
-       noring already-seen entries in import  data,  such  as  downloaded  CSV
+       cial  state  file  (.latest.FILE in the same directory), containing the
+       latest transaction date(s) that were seen  last  time  FILE  was  read.
+       When  this  file  is found, only transactions with newer dates (and new
+       transactions on the latest date) are printed.  This is useful  for  ig-
+       noring  already-seen  entries  in  import  data, such as downloaded CSV
        files.  Eg:
 
               $ hledger -f bank1.csv print --new
               (shows transactions added since last print --new on this file)
 
-       This  assumes  that  transactions added to FILE always have same or in-
-       creasing dates, and that transactions on the same day do  not  get  re-
+       This assumes that transactions added to FILE always have  same  or  in-
+       creasing  dates,  and  that transactions on the same day do not get re-
        ordered.  See also the import command.
 
        This command also supports the output destination and output format op-
-       tions The output formats supported are  txt,  csv,  and  (experimental)
+       tions  The  output  formats  supported are txt, csv, and (experimental)
        json.
 
        Here's an example of print's CSV output:
@@ -2655,20 +2689,20 @@
               "5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","",""
               "5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","",""
 
-       o There  is  one  CSV record per posting, with the parent transaction's
+       o There is one CSV record per posting, with  the  parent  transaction's
          fields repeated.
 
        o 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
+         the same transaction.  (This number might change if transactions  are
+         reordered  within  the file, files are parsed/included in a different
          order, etc.)
 
-       o The  amount  is  separated into "commodity" (the symbol) and "amount"
+       o The amount is separated into "commodity" (the  symbol)  and  "amount"
          (numeric quantity) fields.
 
        o The numeric amount is repeated in either the "credit" or "debit" col-
-         umn,  for convenience.  (Those names are not accurate in the account-
-         ing sense; it just puts negative amounts under  credit  and  zero  or
+         umn, for convenience.  (Those names are not accurate in the  account-
+         ing  sense;  it  just  puts negative amounts under credit and zero or
          greater amounts under debit.)
 
    print-unique
@@ -2692,7 +2726,7 @@
        Show postings and their running total.
 
        The register command displays postings in date order, one per line, and
-       their running total.  This is typically used with a query  selecting  a
+       their  running  total.  This is typically used with a query selecting a
        particular account, to see that account's activity:
 
               $ hledger register checking
@@ -2703,8 +2737,8 @@
 
        With --date2, it shows and sorts by secondary date instead.
 
-       The  --historical/-H  flag  adds the balance from any undisplayed prior
-       postings to the running total.  This is useful when  you  want  to  see
+       The --historical/-H flag adds the balance from  any  undisplayed  prior
+       postings  to  the  running  total.  This is useful when you want to see
        only recent activity, with a historically accurate running balance:
 
               $ hledger register checking -b 2008/6 --historical
@@ -2714,18 +2748,18 @@
 
        The --depth option limits the amount of sub-account detail displayed.
 
-       The  --average/-A flag shows the running average posting amount instead
+       The --average/-A flag shows the running average posting amount  instead
        of the running total (so, the final number displayed is the average for
-       the  whole  report period).  This flag implies --empty (see below).  It
-       is affected by --historical.  It works best when showing just  one  ac-
+       the whole report period).  This flag implies --empty (see  below).   It
+       is  affected  by --historical.  It works best when showing just one ac-
        count and one commodity.
 
-       The  --related/-r  flag shows the other postings in the transactions of
+       The --related/-r flag shows the other postings in the  transactions  of
        the postings which would normally be shown.
 
-       The --invert flag negates all amounts.  For example, it can be used  on
+       The  --invert flag negates all amounts.  For example, it can be used on
        an income account where amounts are normally displayed as negative num-
-       bers.  It's also useful to show postings on the  checking  account  to-
+       bers.   It's  also  useful to show postings on the checking account to-
        gether with the related account:
 
               $ hledger register --related --invert assets:checking
@@ -2737,7 +2771,7 @@
               2008/01                 income:salary                          $-1          $-1
               2008/06                 income:gifts                           $-1          $-2
 
-       Periods with no activity, and summary postings with a zero amount,  are
+       Periods  with no activity, and summary postings with a zero amount, are
        not shown by default; use the --empty/-E flag to see them:
 
               $ hledger register --monthly income -E
@@ -2754,7 +2788,7 @@
               2008/11                                                          0          $-2
               2008/12                                                          0          $-2
 
-       Often,  you'll want to see just one line per interval.  The --depth op-
+       Often, you'll want to see just one line per interval.  The --depth  op-
        tion helps with this, causing subaccounts to be aggregated:
 
               $ hledger register --monthly assets --depth 1h
@@ -2762,17 +2796,17 @@
               2008/06                 assets                                 $-1            0
               2008/12                 assets                                 $-1          $-1
 
-       Note when using report intervals, if you specify start/end dates  these
-       will  be adjusted outward if necessary to contain a whole number of in-
-       tervals.  This ensures that the  first  and  last  intervals  are  full
+       Note  when using report intervals, if you specify start/end dates these
+       will be adjusted outward if necessary to contain a whole number of  in-
+       tervals.   This  ensures  that  the  first  and last intervals are full
        length and comparable to the others in the report.
 
    Custom register output
-       register  uses  the  full terminal width by default, except on windows.
-       You can override this by setting the COLUMNS environment variable  (not
+       register uses the full terminal width by default,  except  on  windows.
+       You  can override this by setting the COLUMNS environment variable (not
        a bash shell variable) or by using the --width/-w option.
 
-       The  description  and  account columns normally share the space equally
+       The description and account columns normally share  the  space  equally
        (about half of (width - 40) each).  You can adjust this by adding a de-
        scription width as part of --width's argument, comma-separated: --width
        W,D .  Here's a diagram (won't display correctly in --help):
@@ -2791,27 +2825,27 @@
               $ hledger reg -w $COLUMNS,40      # use terminal width, & description width 40
 
        This command also supports the output destination and output format op-
-       tions  The  output  formats  supported are txt, csv, and (experimental)
+       tions The output formats supported are  txt,  csv,  and  (experimental)
        json.
 
    register-match
        register-match
        Print the one posting whose transaction description is closest to DESC,
-       in  the  style  of the register command.  If there are multiple equally
-       good matches, it shows the most recent.  Query  options  (options,  not
-       arguments)  can be used to restrict the search space.  Helps ledger-au-
+       in the style of the register command.  If there  are  multiple  equally
+       good  matches,  it  shows the most recent.  Query options (options, not
+       arguments) can be used to restrict the search space.  Helps  ledger-au-
        tosync detect already-seen transactions when importing.
 
    rewrite
        rewrite
        Print all transactions, rewriting the postings of matched transactions.
-       For  now  the only rewrite available is adding new postings, like print
+       For now the only rewrite available is adding new postings,  like  print
        --auto.
 
        This is a start at a generic rewriter of transaction entries.  It reads
-       the  default  journal and prints the transactions, like print, but adds
+       the default journal and prints the transactions, like print,  but  adds
        one or more specified postings to any transactions matching QUERY.  The
-       posting  amounts can be fixed, or a multiplier of the existing transac-
+       posting amounts can be fixed, or a multiplier of the existing  transac-
        tion's first posting amount.
 
        Examples:
@@ -2827,7 +2861,7 @@
                 (reserve:grocery)  *0.25  ; reserve 25% for grocery
                 (reserve:)  *0.25  ; reserve 25% for grocery
 
-       Note the single quotes to protect the dollar sign from  bash,  and  the
+       Note  the  single  quotes to protect the dollar sign from bash, and the
        two spaces between account and amount.
 
        More:
@@ -2837,16 +2871,16 @@
               $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts)  *-1"'
               $ hledger rewrite -- ^income        --add-posting '(budget:foreign currency)  *0.25 JPY; diversify'
 
-       Argument  for  --add-posting  option  is a usual posting of transaction
-       with an exception for amount specification.  More  precisely,  you  can
+       Argument for --add-posting option is a  usual  posting  of  transaction
+       with  an  exception  for amount specification.  More precisely, you can
        use '*' (star symbol) before the amount to indicate that that this is a
-       factor for an amount of original matched posting.  If  the  amount  in-
+       factor  for  an  amount of original matched posting.  If the amount in-
        cludes a commodity name, the new posting amount will be in the new com-
-       modity; otherwise, it will be in the matched posting  amount's  commod-
+       modity;  otherwise,  it will be in the matched posting amount's commod-
        ity.
 
    Re-write rules in a file
-       During  the  run  this  tool will execute so called "Automated Transac-
+       During the run this tool will execute  so  called  "Automated  Transac-
        tions" found in any journal it process.  I.e instead of specifying this
        operations in command line you can put them in a journal file.
 
@@ -2861,7 +2895,7 @@
                   budget:gifts  *-1
                   assets:budget  *1
 
-       Note  that '=' (equality symbol) that is used instead of date in trans-
+       Note that '=' (equality symbol) that is used instead of date in  trans-
        actions you usually write.  It indicates the query by which you want to
        match the posting to add new ones.
 
@@ -2874,12 +2908,12 @@
                                                               --add-posting 'assets:budget  *1'       \
                 > rewritten-tidy-output.journal
 
-       It  is  important  to understand that relative order of such entries in
-       journal is important.  You can re-use result of previously added  post-
+       It is important to understand that relative order of  such  entries  in
+       journal  is important.  You can re-use result of previously added post-
        ings.
 
    Diff output format
-       To  use  this tool for batch modification of your journal files you may
+       To use this tool for batch modification of your journal files  you  may
        find useful output in form of unified diff.
 
               $ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax)  *.33'
@@ -2903,10 +2937,10 @@
 
        If you'll pass this through patch tool you'll get transactions contain-
        ing the posting that matches your query be updated.  Note that multiple
-       files might be update according to list of input  files  specified  via
+       files  might  be  update according to list of input files specified via
        --file options and include directives inside of these files.
 
-       Be  careful.  Whole transaction being re-formatted in a style of output
+       Be careful.  Whole transaction being re-formatted in a style of  output
        from hledger print.
 
        See also:
@@ -2914,48 +2948,48 @@
        https://github.com/simonmichael/hledger/issues/99
 
    rewrite vs. print --auto
-       This command predates print --auto, and currently does  much  the  same
+       This  command  predates  print --auto, and currently does much the same
        thing, but with these differences:
 
-       o with  multiple files, rewrite lets rules in any file affect all other
-         files.  print --auto uses standard directive  scoping;  rules  affect
+       o with multiple files, rewrite lets rules in any file affect all  other
+         files.   print  --auto  uses standard directive scoping; rules affect
          only child files.
 
-       o rewrite's  query  limits which transactions can be rewritten; all are
+       o rewrite's query limits which transactions can be rewritten;  all  are
          printed.  print --auto's query limits which transactions are printed.
 
-       o rewrite applies rules specified on command line or  in  the  journal.
+       o rewrite  applies  rules  specified on command line or in the journal.
          print --auto applies rules specified in the journal.
 
    roi
        roi
-       Shows  the  time-weighted (TWR) and money-weighted (IRR) rate of return
+       Shows the time-weighted (TWR) and money-weighted (IRR) rate  of  return
        on your investments.
 
-       This command assumes that you have account(s)  that  hold  nothing  but
+       This  command  assumes  that  you have account(s) that hold nothing but
        your investments and whenever you record current appraisal/valuation of
        these investments you offset unrealized profit and loss into account(s)
        that, again, hold nothing but unrealized profit and loss.
 
-       Any  transactions  affecting  balance  of investment account(s) and not
-       originating from unrealized profit and loss account(s) are  assumed  to
+       Any transactions affecting balance of  investment  account(s)  and  not
+       originating  from  unrealized profit and loss account(s) are assumed to
        be your investments or withdrawals.
 
-       At  a  minimum,  you need to supply a query (which could be just an ac-
+       At a minimum, you need to supply a query (which could be  just  an  ac-
        count name) to select your investments with --inv, and another query to
        identify your profit and loss transactions with --pnl.
 
-       It  will  compute and display the internalized rate of return (IRR) and
-       time-weighted rate of return (TWR) for your investments  for  the  time
-       period  requested.  Both rates of return are annualized before display,
+       It will compute and display the internalized rate of return  (IRR)  and
+       time-weighted  rate  of  return (TWR) for your investments for the time
+       period requested.  Both rates of return are annualized before  display,
        regardless of the length of reporting interval.
 
    stats
        stats
        Show some journal statistics.
 
-       The stats command displays summary information for the  whole  journal,
-       or  a matched part of it.  With a reporting interval, it shows a report
+       The  stats  command displays summary information for the whole journal,
+       or a matched part of it.  With a reporting interval, it shows a  report
        for each report period.
 
        Example:
@@ -2973,14 +3007,14 @@
               Commodities              : 1 ($)
               Market prices            : 12 ($)
 
-       This command also supports output destination and output format  selec-
+       This  command also supports output destination and output format selec-
        tion.
 
    tags
        tags
-       List  all the tag names used in the journal.  With a TAGREGEX argument,
-       only tag names matching the regular expression (case  insensitive)  are
-       shown.   With QUERY arguments, only transactions matching the query are
+       List all the tag names used in the journal.  With a TAGREGEX  argument,
+       only  tag  names matching the regular expression (case insensitive) are
+       shown.  With QUERY arguments, only transactions matching the query  are
        considered.  With --values flag, the tags' unique values are listed in-
        stead.
 
@@ -2988,13 +3022,13 @@
        test
        Run built-in unit tests.
 
-       This  command  runs the unit tests built in to hledger and hledger-lib,
-       printing the results on stdout.  If any test fails, the exit code  will
+       This command runs the unit tests built in to hledger  and  hledger-lib,
+       printing  the results on stdout.  If any test fails, the exit code will
        be non-zero.
 
-       This  is  mainly used by hledger developers, but you can also use it to
-       sanity-check the installed hledger executable on  your  platform.   All
-       tests  are  expected to pass - if you ever see a failure, please report
+       This is mainly used by hledger developers, but you can also use  it  to
+       sanity-check  the  installed  hledger executable on your platform.  All
+       tests are expected to pass - if you ever see a failure,  please  report
        as a bug!
 
        This command also accepts tasty test runner options, written after a --
@@ -3003,35 +3037,35 @@
 
               $ hledger test -- -pData.Amount --color=never
 
-       For help on these, see  https://github.com/feuerbach/tasty#options  (--
+       For  help  on these, see https://github.com/feuerbach/tasty#options (--
        --help currently doesn't show them).
 
-   Add-on Commands
-       hledger  also  searches  for external add-on commands, and will include
+   Add-on commands
+       hledger also searches for external add-on commands,  and  will  include
        these in the commands list.  These are programs or scripts in your PATH
-       whose  name starts with hledger- and ends with a recognised file exten-
+       whose name starts with hledger- and ends with a recognised file  exten-
        sion (currently: no extension, bat,com,exe, hs,lhs,pl,py,rb,rkt,sh).
 
-       Add-ons can be invoked like any hledger command, but there  are  a  few
+       Add-ons  can  be  invoked like any hledger command, but there are a few
        things to be aware of.  Eg if the hledger-web add-on is installed,
 
-       o hledger  -h  web  shows  hledger's  help,  while hledger web -h shows
+       o hledger -h web shows hledger's  help,  while  hledger  web  -h  shows
          hledger-web's help.
 
-       o Flags specific to the add-on must have a preceding --  to  hide  them
-         from  hledger.   So hledger web --serve --port 9000 will be rejected;
+       o Flags  specific  to  the add-on must have a preceding -- to hide them
+         from hledger.  So hledger web --serve --port 9000 will  be  rejected;
          you must use hledger web -- --serve --port 9000.
 
        o You can always run add-ons directly if preferred: hledger-web --serve
          --port 9000.
 
-       Add-ons  are  a relatively easy way to add local features or experiment
-       with new ideas.  They can be  written  in  any  language,  but  haskell
-       scripts  have  a  big  advantage:  they  can  use the same hledger (and
-       haskell) library functions that built-in commands do, for  command-line
+       Add-ons are a relatively easy way to add local features  or  experiment
+       with  new  ideas.   They  can  be  written in any language, but haskell
+       scripts have a big advantage:  they  can  use  the  same  hledger  (and
+       haskell)  library functions that built-in commands do, for command-line
        options, journal parsing, reporting, etc.
 
-       Two  important  add-ons  are the hledger-ui and hledger-web user inter-
+       Two important add-ons are the hledger-ui and  hledger-web  user  inter-
        faces.  These are maintained and released along with hledger:
 
    ui
@@ -3050,23 +3084,23 @@
        hledger-interest generates interest transactions for an account accord-
        ing to various schemes.
 
-       A few more experimental or old add-ons can be found in  hledger's  bin/
+       A  few  more experimental or old add-ons can be found in hledger's bin/
        directory.  These are typically prototypes and not guaranteed to work.
 
 ENVIRONMENT
-       COLUMNS  The  screen  width used by the register command.  Default: the
+       COLUMNS The screen width used by the register  command.   Default:  the
        full terminal width.
 
        LEDGER_FILE The journal file path when not specified with -f.  Default:
-       ~/.hledger.journal  (on  windows,  perhaps C:/Users/USER/.hledger.jour-
+       ~/.hledger.journal (on  windows,  perhaps  C:/Users/USER/.hledger.jour-
        nal).
 
-       A typical value is ~/DIR/YYYY.journal,  where  DIR  is  a  version-con-
-       trolled  finance directory and YYYY is the current year.  Or ~/DIR/cur-
+       A  typical  value  is  ~/DIR/YYYY.journal,  where DIR is a version-con-
+       trolled finance directory and YYYY is the current year.  Or  ~/DIR/cur-
        rent.journal, where current.journal is a symbolic link to YYYY.journal.
 
        On Mac computers, you can set this and other environment variables in a
-       more  thorough  way that also affects applications started from the GUI
+       more thorough way that also affects applications started from  the  GUI
        (say, an Emacs dock icon).  Eg on MacOS Catalina I have a ~/.MacOSX/en-
        vironment.plist file containing
 
@@ -3077,13 +3111,13 @@
        To see the effect you may need to killall Dock, or reboot.
 
 FILES
-       Reads  data from one or more files in hledger journal, timeclock, time-
-       dot,  or  CSV  format  specified   with   -f,   or   $LEDGER_FILE,   or
-       $HOME/.hledger.journal           (on          windows,          perhaps
+       Reads data from one or more files in hledger journal, timeclock,  time-
+       dot,   or   CSV   format   specified   with  -f,  or  $LEDGER_FILE,  or
+       $HOME/.hledger.journal          (on          windows,           perhaps
        C:/Users/USER/.hledger.journal).
 
 LIMITATIONS
-       The need to precede addon command options with  --  when  invoked  from
+       The  need  to  precede  addon command options with -- when invoked from
        hledger is awkward.
 
        When input data contains non-ascii characters, a suitable system locale
@@ -3099,53 +3133,53 @@
        In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger
        add.
 
-       Not all of Ledger's journal file syntax is supported.  See file  format
+       Not  all of Ledger's journal file syntax is supported.  See file format
        differences.
 
-       On  large  data  files,  hledger  is  slower  and uses more memory than
+       On large data files, hledger  is  slower  and  uses  more  memory  than
        Ledger.
 
 TROUBLESHOOTING
-       Here are some issues you might encounter when you run hledger (and  re-
-       member  you  can  also seek help from the IRC channel, mail list or bug
+       Here  are some issues you might encounter when you run hledger (and re-
+       member you can also seek help from the IRC channel, mail  list  or  bug
        tracker):
 
        Successfully installed, but "No command 'hledger' found"
        stack and cabal install binaries into a special directory, which should
-       be  added  to your PATH environment variable.  Eg on unix-like systems,
+       be added to your PATH environment variable.  Eg on  unix-like  systems,
        that is ~/.local/bin and ~/.cabal/bin respectively.
 
        I set a custom LEDGER_FILE, but hledger is still using the default file
-       LEDGER_FILE should be a real environment variable,  not  just  a  shell
-       variable.   The command env | grep LEDGER_FILE should show it.  You may
+       LEDGER_FILE  should  be  a  real environment variable, not just a shell
+       variable.  The command env | grep LEDGER_FILE should show it.  You  may
        need to use export.  Here's an explanation.
 
-       "Illegal byte sequence" or "Invalid or  incomplete  multibyte  or  wide
-       character" errors
-       In order to handle non-ascii letters and symbols (like ), hledger needs
-       an appropriate locale.  This is usually configured system-wide; you can
-       also configure it temporarily.  The locale may need to be one that sup-
-       ports UTF-8, if you built hledger with GHC < 7.2 (or  possibly  always,
-       I'm not sure yet).
+       Getting  errors  like "Illegal byte sequence" or "Invalid or incomplete
+       multibyte or wide character" or "commitAndReleaseBuffer: invalid  argu-
+       ment (invalid character)"
+       Programs compiled with GHC (hledger, haskell build tools, etc.) need to
+       have a UTF-8-aware locale configured in the environment, otherwise they
+       will  fail  with  these  kinds  of errors when they encounter non-ascii
+       characters.
 
-       Here's  an  example  of  setting  the  locale  temporarily,  on  ubuntu
-       gnu/linux:
+       To fix it, set the LANG environment variable to some locale which  sup-
+       ports UTF-8.  The locale you choose must be installed on your system.
 
+       Here's an example of setting LANG temporarily, on Ubuntu GNU/Linux:
+
               $ file my.journal
-              my.journal: UTF-8 Unicode text                 # <- the file is UTF8-encoded
-              $ locale -a
+              my.journal: UTF-8 Unicode text         # the file is UTF8-encoded
+              $ echo $LANG
+              C                                      # LANG is set to the default locale, which does not support UTF8
+              $ locale -a                            # which locales are installed ?
               C
-              en_US.utf8                             # <- a UTF8-aware locale is available
+              en_US.utf8                             # here's a UTF8-aware one we can use
               POSIX
-              $ LANG=en_US.utf8 hledger -f my.journal print   # <- use it for this command
-
-       Here's one way to set it permanently, there are probably better ways:
-
-              $ echo "export LANG=en_US.UTF-8" >>~/.bash_profile
-              $ bash --login
+              $ LANG=en_US.utf8 hledger -f my.journal print   # ensure it is used for this command
 
-       If we preferred to use eg fr_FR.utf8, we might  have  to  install  that
-       first:
+       If  available,  C.UTF-8 will also work.  If your preferred locale isn't
+       listed by locale -a, you might need to install it.   Eg  on  Ubuntu/De-
+       bian:
 
               $ apt-get install language-pack-fr
               $ locale -a
@@ -3159,13 +3193,23 @@
               POSIX
               $ LANG=fr_FR.utf8 hledger -f my.journal print
 
-       Note some platforms allow variant locale spellings, but not all (ubuntu
-       accepts fr_FR.UTF8, mac osx requires exactly fr_FR.UTF-8).
+       Here's how you could set it permanently, if you use a bash shell:
 
+              $ echo "export LANG=en_US.utf8" >>~/.bash_profile
+              $ bash --login
 
+       Exact  spelling  and capitalisation may be important.  Note the differ-
+       ence on MacOS (UTF-8, not utf8).   Some  platforms  (eg  ubuntu)  allow
+       variant spellings, but others (eg macos) require it to be exact:
 
+              $ locale -a | grep -iE en_us.*utf
+              en_US.UTF-8
+              $ LANG=en_US.UTF-8 hledger -f my.journal print
+
+
+
 REPORTING BUGS
-       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel
+       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel
        or hledger mail list)
 
 
@@ -3179,7 +3223,7 @@
 
 
 SEE ALSO
-       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),
+       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),
        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
        dot(5), ledger(1)
 
@@ -3187,4 +3231,4 @@
 
 
 
-hledger 1.17.1.1                  March 2020                        hledger(1)
+hledger 1.18                       June 2020                        hledger(1)
