public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* I need tables in ConTeXt output to NOT float
@ 2021-06-14 16:08 T. Kurt Bond
       [not found] ` <CAN1EhV-Oe9U__+PyDfajyYDoODS6_7OWPxF33LLWiG6gQEmrpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: T. Kurt Bond @ 2021-06-14 16:08 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1029 bytes --]

When the ConTeXt writer produces tables it starts with

\startplacetable[title={Table Caption}]

if the table has a caption, or

\startplacetable[location=none]

This allows the tables to float.

I need tables to *not* float.  For tables with captions I want them to
start with

\startplacetable[location=force,title={Table Caption}]

and for tables without captions I want them to start with

\startplacetable[location={force,none}]

Would it be possible to add an option to force the tables not to float?
-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV-Oe9U__%2BPyDfajyYDoODS6_7OWPxF33LLWiG6gQEmrpA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 2219 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: I need tables in ConTeXt output to NOT float
       [not found] ` <CAN1EhV-Oe9U__+PyDfajyYDoODS6_7OWPxF33LLWiG6gQEmrpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-06-15 10:22   ` 'Frederik Elwert' via pandoc-discuss
  2021-06-15 14:39   ` AW: " denis.maier-NSENcxR/0n0
  2021-07-14 21:54   ` T. Kurt Bond
  2 siblings, 0 replies; 9+ messages in thread
From: 'Frederik Elwert' via pandoc-discuss @ 2021-06-15 10:22 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1913 bytes --]

 I don’t have a solution for this, but I wanted to mention that there’s the 
opposite issue in LaTeX output: Because it uses `longtable` for tables (and 
understandably this is a good default solution in many cases), LaTeX tables 
produced by pandoc _don’t_ float. This strips LaTeX output of one of its 
central features that make it superior when compared to Word etc.

I tried to add floating tables with a custom filter, but that basically 
means re-constructing the complete LaTeX code that a table can contain 
within the filter.

So while I don’t have an easy solution, I agree that a bit more control 
over table rendering/positioning in ConTeXt and LaTeX would be much 
appreciated.

Frederik

tkur...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org schrieb am Montag, 14. Juni 2021 um 18:08:30 UTC+2:

> When the ConTeXt writer produces tables it starts with 
>
> \startplacetable[title={Table Caption}]
>
> if the table has a caption, or 
>
> \startplacetable[location=none]
>
> This allows the tables to float.
>
> I need tables to *not* float.  For tables with captions I want them to 
> start with 
>
> \startplacetable[location=force,title={Table Caption}]
>
> and for tables without captions I want them to start with 
>
> \startplacetable[location={force,none}]
>
> Would it be possible to add an option to force the tables not to float?
> -- 
> T. Kurt Bond, tkur...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/956ccb4f-ce76-4b84-93be-af36607a0496n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3394 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* AW: I need tables in ConTeXt output to NOT float
       [not found] ` <CAN1EhV-Oe9U__+PyDfajyYDoODS6_7OWPxF33LLWiG6gQEmrpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2021-06-15 10:22   ` 'Frederik Elwert' via pandoc-discuss
@ 2021-06-15 14:39   ` denis.maier-NSENcxR/0n0
       [not found]     ` <eace606fe51249efa0393dda0e829959-NSENcxR/0n0@public.gmane.org>
  2021-07-14 21:54   ` T. Kurt Bond
  2 siblings, 1 reply; 9+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2021-06-15 14:39 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 2661 bytes --]

Hi,

I also don’t have an easy solution, but you might want to consider going through XHTML rather than directly to ConTeXt. As ConTeXt can process XML files this might give you more options. Pablo’s XHTML mapping (https://github.com/ousia/from-pandoc-to-context) should get you started. (There’s also a slightly extended version at https://github.com/juh2/from-pandoc-to-context).

With that, you’ll be able to wrap your tables in divs and treat them differently depending on arbitrary attributes. Think of this:


::: {.floatingTable}
your table
:::

or


::: {float="true"}
your table
:::

Then

Best,
Denis

Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von T. Kurt Bond
Gesendet: Montag, 14. Juni 2021 18:08
An: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Betreff: I need tables in ConTeXt output to NOT float

When the ConTeXt writer produces tables it starts with
\startplacetable[title={Table Caption}]
if the table has a caption, or
\startplacetable[location=none]
This allows the tables to float.

I need tables to not float.  For tables with captions I want them to start with
\startplacetable[location=force,title={Table Caption}]
and for tables without captions I want them to start with
\startplacetable[location={force,none}]
Would it be possible to add an option to force the tables not to float?
--
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<mailto:tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>, https://tkurtbond.github.io
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV-Oe9U__%2BPyDfajyYDoODS6_7OWPxF33LLWiG6gQEmrpA%40mail.gmail.com<https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV-Oe9U__%2BPyDfajyYDoODS6_7OWPxF33LLWiG6gQEmrpA%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/eace606fe51249efa0393dda0e829959%40unibe.ch.

[-- Attachment #2: Type: text/html, Size: 8630 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: AW: I need tables in ConTeXt output to NOT float
       [not found]     ` <eace606fe51249efa0393dda0e829959-NSENcxR/0n0@public.gmane.org>
@ 2021-07-14 19:26       ` T. Kurt Bond
  0 siblings, 0 replies; 9+ messages in thread
From: T. Kurt Bond @ 2021-07-14 19:26 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On Tue, 15 Jun 2021 10:39:27 -0400,
<denis.maier-NSENcxR/0n0@public.gmane.org> wrote:

> I also don’t have an easy solution, but you might want to consider
> going through XHTML rather than directly to ConTeXt. As ConTeXt can
> process XML files this might give you more options. Pablo’s XHTML
> mapping (https://github.com/ousia/from-pandoc-to-context) should get
> you started. (There’s also a slightly extended version at
> https://github.com/juh2/from-pandoc-to-context).

Unfortunately, my document source is reStructuredText, so the this won't help
in this case.  I'll keep it in mind for markdown documents.

-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, tkurtbond.github.io and tkb.tx0.org

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2wnps1yuf.wl-tkurtbond%40gmail.com.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: I need tables in ConTeXt output to NOT float
       [not found] ` <CAN1EhV-Oe9U__+PyDfajyYDoODS6_7OWPxF33LLWiG6gQEmrpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2021-06-15 10:22   ` 'Frederik Elwert' via pandoc-discuss
  2021-06-15 14:39   ` AW: " denis.maier-NSENcxR/0n0
@ 2021-07-14 21:54   ` T. Kurt Bond
       [not found]     ` <CAN1EhV94hy6m=KQ4A8=9PaRH=+VbR36oU-OwhAAj4=h1XHztCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2 siblings, 1 reply; 9+ messages in thread
From: T. Kurt Bond @ 2021-07-14 21:54 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 1520 bytes --]

I've made a patch against git head, commit
06408d08e5ccf06a6a04c9b77470e6a67d98e52c,  that implements a
--no-table-float writer option for the ConTeXt writer.  I've attached it
to this email.

Any hope of something like this being accepted?

On Mon, Jun 14, 2021 at 12:08 PM T. Kurt Bond <tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> When the ConTeXt writer produces tables it starts with
>
> \startplacetable[title={Table Caption}]
>
> if the table has a caption, or
>
> \startplacetable[location=none]
>
> This allows the tables to float.
>
> I need tables to *not* float.  For tables with captions I want them to
> start with
>
> \startplacetable[location=force,title={Table Caption}]
>
> and for tables without captions I want them to start with
>
> \startplacetable[location={force,none}]
>
> Would it be possible to add an option to force the tables not to float?
> --
> T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io
>


-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV94hy6m%3DKQ4A8%3D9PaRH%3D%2BVbR36oU-OwhAAj4%3Dh1XHztCA%40mail.gmail.com.

[-- Attachment #1.2: Type: text/html, Size: 3283 bytes --]

[-- Attachment #2: no-table-force.patch --]
[-- Type: application/octet-stream, Size: 4234 bytes --]

diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
index a6df12715..9b2c4f699 100644
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -958,6 +958,10 @@ options =
                      UTF8.hPutStr stdout (T.pack $ usageMessage prg options)
                      exitSuccess ))
                  "" -- "Show help"
+    , Option "" ["no-table-float"]
+                (NoArg
+                 (\opt -> return opt { optTableFloat = False }))
+                "" -- "Do not let tables float"
     ]
 
 getDataFileNames :: IO [FilePath]
diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs
index d54d932b7..68f74eddc 100644
--- a/src/Text/Pandoc/App/Opt.hs
+++ b/src/Text/Pandoc/App/Opt.hs
@@ -160,6 +160,7 @@ data Opt = Opt
     , optCSL                   :: Maybe FilePath -- ^ CSL stylesheet
     , optBibliography          :: [FilePath]  -- ^ Bibliography files
     , optCitationAbbreviations :: Maybe FilePath -- ^ Citation abbreviations
+    , optTableFloat            :: Bool           -- ^ Disable tables floating
     } deriving (Generic, Show)
 
 instance FromYAML (Opt -> Opt) where
@@ -673,6 +674,7 @@ defaultOpts = Opt
     , optCSL                   = Nothing
     , optBibliography          = []
     , optCitationAbbreviations = Nothing
+    , optTableFloat            = False
     }
 
 parseStringKey ::  Node Pos -> Parser Text
diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs
index 3864ab188..45634a705 100644
--- a/src/Text/Pandoc/App/OutputSettings.hs
+++ b/src/Text/Pandoc/App/OutputSettings.hs
@@ -211,6 +211,7 @@ optToOutputSettings opts = do
         , writerReferenceDoc     = optReferenceDoc opts
         , writerSyntaxMap        = syntaxMap
         , writerPreferAscii      = optAscii opts
+        , writerTableFloat       = optTableFloat opts
         }
   return $ OutputSettings
     { outputFormat = format
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index 85d9aa103..77184a124 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -265,6 +265,7 @@ data WriterOptions = WriterOptions
   , writerReferenceLocation :: ReferenceLocation    -- ^ Location of footnotes and references for writing markdown
   , writerSyntaxMap         :: SyntaxMap
   , writerPreferAscii       :: Bool           -- ^ Prefer ASCII representations of characters when possible
+  , writerTableFloat        :: Bool           -- ^ Do not let tables float
   } deriving (Show, Data, Typeable, Generic)
 
 instance Default WriterOptions where
@@ -300,6 +301,7 @@ instance Default WriterOptions where
                       , writerReferenceLocation = EndOfDocument
                       , writerSyntaxMap        = defaultSyntaxMap
                       , writerPreferAscii      = False
+                      , writerTableFloat       = True
                       }
 
 instance HasSyntaxExtensions WriterOptions where
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index 3cafcefba..b31df2540 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -259,6 +259,7 @@ blockToConTeXt (Table _ blkCapt specs thead tbody tfoot) = do
     let tabl = if isEnabled Ext_ntb opts
           then Ntb
           else Xtb
+    let flt = writerTableFloat opts
     captionText <- inlineListToConTeXt caption
     headers <- if all null heads
                then return empty
@@ -266,9 +267,13 @@ blockToConTeXt (Table _ blkCapt specs thead tbody tfoot) = do
     rows' <- mapM (tableRowToConTeXt tabl aligns widths) rows
     body <- tableToConTeXt tabl headers rows'
     return $ "\\startplacetable" <> brackets (
-      if null caption
-        then "location=none"
-        else "title=" <> braces captionText
+      if flt
+         then if null caption
+                then "location=none"
+                else "title=" <> braces captionText
+         else if null caption
+                then "location={none,force}"
+                else "title=" <> braces captionText
       ) $$ body $$ "\\stopplacetable" <> blankline
 
 tableToConTeXt :: PandocMonad m

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: I need tables in ConTeXt output to NOT float
       [not found]     ` <CAN1EhV94hy6m=KQ4A8=9PaRH=+VbR36oU-OwhAAj4=h1XHztCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-07-15  1:00       ` T. Kurt Bond
       [not found]         ` <CAN1EhV_dFDBA28NCsXAiTS+f-nAQCx5zLymm=tAywQ9XHj1OQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: T. Kurt Bond @ 2021-07-15  1:00 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1934 bytes --]

Ok, I did something wrong.  It compiles, but it always outputs the
non-floating version.  I'm a programmer, but I don't know Haskell, alas.
(I'm learning.)

Any ideas?



On Wed, Jul 14, 2021 at 5:54 PM T. Kurt Bond <tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> I've made a patch against git head, commit
> 06408d08e5ccf06a6a04c9b77470e6a67d98e52c,  that implements a
> --no-table-float writer option for the ConTeXt writer.  I've attached it
> to this email.
>
> Any hope of something like this being accepted?
>
> On Mon, Jun 14, 2021 at 12:08 PM T. Kurt Bond <tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> When the ConTeXt writer produces tables it starts with
>>
>> \startplacetable[title={Table Caption}]
>>
>> if the table has a caption, or
>>
>> \startplacetable[location=none]
>>
>> This allows the tables to float.
>>
>> I need tables to *not* float.  For tables with captions I want them to
>> start with
>>
>> \startplacetable[location=force,title={Table Caption}]
>>
>> and for tables without captions I want them to start with
>>
>> \startplacetable[location={force,none}]
>>
>> Would it be possible to add an option to force the tables not to float?
>> --
>> T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io
>>
>
>
> --
> T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io
>


-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV_dFDBA28NCsXAiTS%2Bf-nAQCx5zLymm%3DtAywQ9XHj1OQA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 4249 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: I need tables in ConTeXt output to NOT float
       [not found]         ` <CAN1EhV_dFDBA28NCsXAiTS+f-nAQCx5zLymm=tAywQ9XHj1OQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-07-15  3:28           ` T. Kurt Bond
       [not found]             ` <CAN1EhV-v2rayAb+oWQbcPcjccXcfRqwwdjpwjdn8g3==bhb6OA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: T. Kurt Bond @ 2021-07-15  3:28 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 552 bytes --]

Ok, here's a fixed patch.
-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV-v2rayAb%2BoWQbcPcjccXcfRqwwdjpwjdn8g3%3D%3Dbhb6OA%40mail.gmail.com.

[-- Attachment #1.2: Type: text/html, Size: 1162 bytes --]

[-- Attachment #2: no-table-force.patch --]
[-- Type: application/octet-stream, Size: 4227 bytes --]

diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
index a6df12715..9b2c4f699 100644
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -958,6 +958,10 @@ options =
                      UTF8.hPutStr stdout (T.pack $ usageMessage prg options)
                      exitSuccess ))
                  "" -- "Show help"
+    , Option "" ["no-table-float"]
+                (NoArg
+                 (\opt -> return opt { optTableFloat = False }))
+                "" -- "Do not let tables float"
     ]
 
 getDataFileNames :: IO [FilePath]
diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs
index d54d932b7..569d6d82c 100644
--- a/src/Text/Pandoc/App/Opt.hs
+++ b/src/Text/Pandoc/App/Opt.hs
@@ -160,6 +160,7 @@ data Opt = Opt
     , optCSL                   :: Maybe FilePath -- ^ CSL stylesheet
     , optBibliography          :: [FilePath]  -- ^ Bibliography files
     , optCitationAbbreviations :: Maybe FilePath -- ^ Citation abbreviations
+    , optTableFloat            :: Bool           -- ^ Should tables float?
     } deriving (Generic, Show)
 
 instance FromYAML (Opt -> Opt) where
@@ -673,6 +674,7 @@ defaultOpts = Opt
     , optCSL                   = Nothing
     , optBibliography          = []
     , optCitationAbbreviations = Nothing
+    , optTableFloat            = True
     }
 
 parseStringKey ::  Node Pos -> Parser Text
diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs
index 3864ab188..45634a705 100644
--- a/src/Text/Pandoc/App/OutputSettings.hs
+++ b/src/Text/Pandoc/App/OutputSettings.hs
@@ -211,6 +211,7 @@ optToOutputSettings opts = do
         , writerReferenceDoc     = optReferenceDoc opts
         , writerSyntaxMap        = syntaxMap
         , writerPreferAscii      = optAscii opts
+        , writerTableFloat       = optTableFloat opts
         }
   return $ OutputSettings
     { outputFormat = format
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index 85d9aa103..8a09a84ac 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -265,6 +265,7 @@ data WriterOptions = WriterOptions
   , writerReferenceLocation :: ReferenceLocation    -- ^ Location of footnotes and references for writing markdown
   , writerSyntaxMap         :: SyntaxMap
   , writerPreferAscii       :: Bool           -- ^ Prefer ASCII representations of characters when possible
+  , writerTableFloat        :: Bool           -- ^ Should tables float?
   } deriving (Show, Data, Typeable, Generic)
 
 instance Default WriterOptions where
@@ -300,6 +301,7 @@ instance Default WriterOptions where
                       , writerReferenceLocation = EndOfDocument
                       , writerSyntaxMap        = defaultSyntaxMap
                       , writerPreferAscii      = False
+                      , writerTableFloat       = True
                       }
 
 instance HasSyntaxExtensions WriterOptions where
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index 3cafcefba..b31df2540 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -259,6 +259,7 @@ blockToConTeXt (Table _ blkCapt specs thead tbody tfoot) = do
     let tabl = if isEnabled Ext_ntb opts
           then Ntb
           else Xtb
+    let flt = writerTableFloat opts
     captionText <- inlineListToConTeXt caption
     headers <- if all null heads
                then return empty
@@ -266,9 +267,13 @@ blockToConTeXt (Table _ blkCapt specs thead tbody tfoot) = do
     rows' <- mapM (tableRowToConTeXt tabl aligns widths) rows
     body <- tableToConTeXt tabl headers rows'
     return $ "\\startplacetable" <> brackets (
-      if null caption
-        then "location=none"
-        else "title=" <> braces captionText
+      if flt
+         then if null caption
+                then "location=none"
+                else "title=" <> braces captionText
+         else if null caption
+                then "location={none,force}"
+                else "title=" <> braces captionText
       ) $$ body $$ "\\stopplacetable" <> blankline
 
 tableToConTeXt :: PandocMonad m

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: I need tables in ConTeXt output to NOT float
       [not found]             ` <CAN1EhV-v2rayAb+oWQbcPcjccXcfRqwwdjpwjdn8g3==bhb6OA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-07-15  3:50               ` T. Kurt Bond
       [not found]                 ` <CAN1EhV-gLh=HsNf9kwT3dqLnbUXW27PDrQkJy5wL_QcbM6rfCg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: T. Kurt Bond @ 2021-07-15  3:50 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 1063 bytes --]

Argh!  Well, third times a charm?  I didn't realize that
\placetable[location={none,force}]
doesn't quite do the same thing as \placetable[location={force,none}].  I
needed the latter.  Sigh.  I've attached a third version of the patch.

This really does make a big difference for one of my documents.

On Wed, Jul 14, 2021 at 11:28 PM T. Kurt Bond <tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Ok, here's a fixed patch.
> --
> T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io
>


-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV-gLh%3DHsNf9kwT3dqLnbUXW27PDrQkJy5wL_QcbM6rfCg%40mail.gmail.com.

[-- Attachment #1.2: Type: text/html, Size: 2310 bytes --]

[-- Attachment #2: no-table-force-3.patch --]
[-- Type: application/octet-stream, Size: 4227 bytes --]

diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
index a6df12715..9b2c4f699 100644
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -958,6 +958,10 @@ options =
                      UTF8.hPutStr stdout (T.pack $ usageMessage prg options)
                      exitSuccess ))
                  "" -- "Show help"
+    , Option "" ["no-table-float"]
+                (NoArg
+                 (\opt -> return opt { optTableFloat = False }))
+                "" -- "Do not let tables float"
     ]
 
 getDataFileNames :: IO [FilePath]
diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs
index d54d932b7..569d6d82c 100644
--- a/src/Text/Pandoc/App/Opt.hs
+++ b/src/Text/Pandoc/App/Opt.hs
@@ -160,6 +160,7 @@ data Opt = Opt
     , optCSL                   :: Maybe FilePath -- ^ CSL stylesheet
     , optBibliography          :: [FilePath]  -- ^ Bibliography files
     , optCitationAbbreviations :: Maybe FilePath -- ^ Citation abbreviations
+    , optTableFloat            :: Bool           -- ^ Should tables float?
     } deriving (Generic, Show)
 
 instance FromYAML (Opt -> Opt) where
@@ -673,6 +674,7 @@ defaultOpts = Opt
     , optCSL                   = Nothing
     , optBibliography          = []
     , optCitationAbbreviations = Nothing
+    , optTableFloat            = True
     }
 
 parseStringKey ::  Node Pos -> Parser Text
diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs
index 3864ab188..45634a705 100644
--- a/src/Text/Pandoc/App/OutputSettings.hs
+++ b/src/Text/Pandoc/App/OutputSettings.hs
@@ -211,6 +211,7 @@ optToOutputSettings opts = do
         , writerReferenceDoc     = optReferenceDoc opts
         , writerSyntaxMap        = syntaxMap
         , writerPreferAscii      = optAscii opts
+        , writerTableFloat       = optTableFloat opts
         }
   return $ OutputSettings
     { outputFormat = format
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index 85d9aa103..8a09a84ac 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -265,6 +265,7 @@ data WriterOptions = WriterOptions
   , writerReferenceLocation :: ReferenceLocation    -- ^ Location of footnotes and references for writing markdown
   , writerSyntaxMap         :: SyntaxMap
   , writerPreferAscii       :: Bool           -- ^ Prefer ASCII representations of characters when possible
+  , writerTableFloat        :: Bool           -- ^ Should tables float?
   } deriving (Show, Data, Typeable, Generic)
 
 instance Default WriterOptions where
@@ -300,6 +301,7 @@ instance Default WriterOptions where
                       , writerReferenceLocation = EndOfDocument
                       , writerSyntaxMap        = defaultSyntaxMap
                       , writerPreferAscii      = False
+                      , writerTableFloat       = True
                       }
 
 instance HasSyntaxExtensions WriterOptions where
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index 3cafcefba..26836e7c1 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -259,6 +259,7 @@ blockToConTeXt (Table _ blkCapt specs thead tbody tfoot) = do
     let tabl = if isEnabled Ext_ntb opts
           then Ntb
           else Xtb
+    let flt = writerTableFloat opts
     captionText <- inlineListToConTeXt caption
     headers <- if all null heads
                then return empty
@@ -266,9 +267,13 @@ blockToConTeXt (Table _ blkCapt specs thead tbody tfoot) = do
     rows' <- mapM (tableRowToConTeXt tabl aligns widths) rows
     body <- tableToConTeXt tabl headers rows'
     return $ "\\startplacetable" <> brackets (
-      if null caption
-        then "location=none"
-        else "title=" <> braces captionText
+      if flt
+         then if null caption
+                then "location=none"
+                else "title=" <> braces captionText
+         else if null caption
+                then "location={force,none}"
+                else "title=" <> braces captionText
       ) $$ body $$ "\\stopplacetable" <> blankline
 
 tableToConTeXt :: PandocMonad m

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: I need tables in ConTeXt output to NOT float
       [not found]                 ` <CAN1EhV-gLh=HsNf9kwT3dqLnbUXW27PDrQkJy5wL_QcbM6rfCg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-07-16  2:17                   ` T. Kurt Bond
  0 siblings, 0 replies; 9+ messages in thread
From: T. Kurt Bond @ 2021-07-16  2:17 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1346 bytes --]

Would it be better if I made a pull request with this?

On Wed, Jul 14, 2021 at 11:50 PM T. Kurt Bond <tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Argh!  Well, third times a charm?  I didn't realize that \placetable[location={none,force}]
> doesn't quite do the same thing as \placetable[location={force,none}].  I
> needed the latter.  Sigh.  I've attached a third version of the patch.
>
> This really does make a big difference for one of my documents.
>
> On Wed, Jul 14, 2021 at 11:28 PM T. Kurt Bond <tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> Ok, here's a fixed patch.
>> --
>> T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io
>>
>
>
> --
> T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io
>


-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV8J6UbxKS6TbiO3NXjrJc2YLvwswZFRzrnRkVykQKOLyg%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 3158 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-07-16  2:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 16:08 I need tables in ConTeXt output to NOT float T. Kurt Bond
     [not found] ` <CAN1EhV-Oe9U__+PyDfajyYDoODS6_7OWPxF33LLWiG6gQEmrpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-06-15 10:22   ` 'Frederik Elwert' via pandoc-discuss
2021-06-15 14:39   ` AW: " denis.maier-NSENcxR/0n0
     [not found]     ` <eace606fe51249efa0393dda0e829959-NSENcxR/0n0@public.gmane.org>
2021-07-14 19:26       ` T. Kurt Bond
2021-07-14 21:54   ` T. Kurt Bond
     [not found]     ` <CAN1EhV94hy6m=KQ4A8=9PaRH=+VbR36oU-OwhAAj4=h1XHztCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-07-15  1:00       ` T. Kurt Bond
     [not found]         ` <CAN1EhV_dFDBA28NCsXAiTS+f-nAQCx5zLymm=tAywQ9XHj1OQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-07-15  3:28           ` T. Kurt Bond
     [not found]             ` <CAN1EhV-v2rayAb+oWQbcPcjccXcfRqwwdjpwjdn8g3==bhb6OA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-07-15  3:50               ` T. Kurt Bond
     [not found]                 ` <CAN1EhV-gLh=HsNf9kwT3dqLnbUXW27PDrQkJy5wL_QcbM6rfCg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-07-16  2:17                   ` T. Kurt Bond

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).