public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* format code in cells of a table
@ 2020-11-27 10:15 Joe Cordingley
       [not found] ` <b88703d3-70e7-4189-a5ea-202e19d7b5f2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Cordingley @ 2020-11-27 10:15 UTC (permalink / raw)
  To: pandoc-discuss


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


I was trying to see if I could put code blocks in a table, so I could 
compare code blocks side by side. For example this:

-----------------------------------------------------------------------------------
scala                                          haskell
---------------------------------------------- 
------------------------------------
`sealed trait Player` \                        `data Player` \
`case object PlayerOne extends Player` \       `  = Player One` \
`case object PlayerTwo extends Player` \       `  | Player Two` \
                                              
`def nextPlayer: Player => Player = {` \       `nextPlayer :: Player -> 
Player` \
`  case PlayerOne => PlayerTwo` \              `nextPlayer PlayerOne = 
PlayerTwo` \
`  case PlayerTwo => PlayerOne` \              `nextPlayer PlayerTwo = 
PlayerOne` \
`}` \

`implicit val showPlayer: Show[Player] = {` \  `instance Show Player where` 
\
`  case PlayerOne => "Player One"` \           `  show PlayerOne = "Player 
One"` \
`  case PlayerTwo => "Player One"` \           `  show PlayerTwo = "Player 
Two"` \
`}` \
-----------------------------------------------------------------------------------

And it very nearly works, however if you zoom the screen out you can see 
that rather than enforcing the newlines it only does so if they don't 
completely fit on the previous line.

Is there a better way of doing this?

-- 
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/b88703d3-70e7-4189-a5ea-202e19d7b5f2n%40googlegroups.com.

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

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

* Re: format code in cells of a table
       [not found] ` <b88703d3-70e7-4189-a5ea-202e19d7b5f2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-11-27 15:52   ` Gwern Branwen
  2020-11-28 20:22   ` John Gabriele
  1 sibling, 0 replies; 3+ messages in thread
From: Gwern Branwen @ 2020-11-27 15:52 UTC (permalink / raw)
  To: pandoc-discuss

Wouldn't it make more sense to avoid the simple or pipe table formats,
and use the grid table format which is the only one which really
supports block elements such as code blocks (as opposed to just inline
code tags): https://pandoc.org/MANUAL.html#extension-grid_tables ?

-- 
gwern
https://www.gwern.net


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

* Re: format code in cells of a table
       [not found] ` <b88703d3-70e7-4189-a5ea-202e19d7b5f2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-11-27 15:52   ` Gwern Branwen
@ 2020-11-28 20:22   ` John Gabriele
  1 sibling, 0 replies; 3+ messages in thread
From: John Gabriele @ 2020-11-28 20:22 UTC (permalink / raw)
  To: pandoc-discuss

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

In the distant past I've done this with (using your titles) :

~~~
Hi.

<table width="100%">
<tr><th>Scala</th><th>Haskell</th></tr>
<tr>
<td width="50%">

~~~scala
scala code here
~~~

</td>
<td width="50%">

~~~haskell
haskell code here
~~~

</td>
</tr>
</table>

... and so on for next pair of side-by-side code blocks.
~~~

Then at some point after that I wrote a short script to turn:

~~~
Hi.

---Scala---
scala code here
---Haskell---
haskell code here
---

... and so on for next pair of side-by-side code blocks.
~~~

Into that same table above.

To do that again these days, I'd probably change my script to output divs & spans to do the same thing using css and maybe flexbox or something.

-- John




On Fri, Nov 27, 2020, at 5:15 AM, Joe Cordingley wrote:
> 
> I was trying to see if I could put code blocks in a table, so I could compare code blocks side by side. For example this:
> 
> -----------------------------------------------------------------------------------
> scala                                          haskell
> ---------------------------------------------- ------------------------------------
> `sealed trait Player` \                        `data Player` \
> `case object PlayerOne extends Player` \       `  = Player One` \
> `case object PlayerTwo extends Player` \       `  | Player Two` \
>                                               
> `def nextPlayer: Player => Player = {` \       `nextPlayer :: Player -> Player` \
> `  case PlayerOne => PlayerTwo` \              `nextPlayer PlayerOne = PlayerTwo` \
> `  case PlayerTwo => PlayerOne` \              `nextPlayer PlayerTwo = PlayerOne` \
> `}` \
> 
> `implicit val showPlayer: Show[Player] = {` \  `instance Show Player where` \
> `  case PlayerOne => "Player One"` \           `  show PlayerOne = "Player One"` \
> `  case PlayerTwo => "Player One"` \           `  show PlayerTwo = "Player Two"` \
> `}` \
> -----------------------------------------------------------------------------------
> 
> And it very nearly works, however if you zoom the screen out you can see that rather than enforcing the newlines it only does so if they don't completely fit on the previous line.
> 
> Is there a better way of doing this?
> 

> -- 
> 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/b88703d3-70e7-4189-a5ea-202e19d7b5f2n%40googlegroups.com <https://groups.google.com/d/msgid/pandoc-discuss/b88703d3-70e7-4189-a5ea-202e19d7b5f2n%40googlegroups.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/caa778d6-e450-4e02-ae11-5d73473a116e%40www.fastmail.com.

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

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

end of thread, other threads:[~2020-11-28 20:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27 10:15 format code in cells of a table Joe Cordingley
     [not found] ` <b88703d3-70e7-4189-a5ea-202e19d7b5f2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-11-27 15:52   ` Gwern Branwen
2020-11-28 20:22   ` John Gabriele

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).