githree
2018-7-11 11:53:19

how can I embedd svg snippet in the scribble/manual?


githree
2018-7-11 11:54:17

eg. #lang scribble/manual @(require racket/format) @(define sample-svg @~a{ &lt;?xml version="1.0"?&gt; &lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "<http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd>"&gt; &lt;svg xmlns="<http://www.w3.org/2000/svg>" width="467" height="462"&gt; &lt;rect x="80" y="60" width="250" height="250" rx="20" style="fill:#ff0000; stroke:#000000;stroke-width:2px;" /&gt; &lt;rect x="140" y="120" width="250" height="250" rx="40" style="fill:#0000ff; stroke:#000000; stroke-width:2px; fill-opacity:0.7;" /&gt; &lt;/svg&gt;})


githree
2018-7-11 11:55:00

I want sample-svg to be rendered as graphics as part of the manual


greg
2018-7-11 11:57:09

@pocmatos If you have a namespace for the file (or for a submodule in the file) you can use namespace-mapped-symbols to get the candidates. Yes I’ve thought about it: https://github.com/greghendershott/racket-mode/blob/master/racket-complete.el#L85-L86 :slightly_smiling_face: In recent years the preferred way to interface with company-mode is to append these to the list returned by the bog standard completion-at-point-function.


greg
2018-7-11 11:58:18

@githree As it happens I just read yesterday on racket-users mailing list about using @literal to include things in HTML.



greg
2018-7-11 12:02:36

FWIW I like to define SVGs using Racket x-exprs then xexpr->string them. But if you’re copying chunks from existing SVG it’s easier to stick with the text XML.


pocmatos
2018-7-11 12:02:41

@greg interesting, so I could use racket-complete-at-point and use that as a backend to company-mode?


greg
2018-7-11 12:04:26

@pocmatos It is (supposed to) “just work” if you enabled company-mode in a racket-mode buffer.


githree
2018-7-11 12:05:18

@greg thank, I can’t make it work though, and in my case the svg will be auto generated -> is literal expected to print the xml or render the graphics (which is what I want?)


greg
2018-7-11 12:05:30

(company-mode says, lemme get the completion-at-point-function for this buffer. Oh, it gave me those :company-xxx values. I’ll use them. i.e. I don’t have any config in my init.el.)


pocmatos
2018-7-11 12:06:17

Oh. OK. Should have tried that.


greg
2018-7-11 12:06:20

@githree Derp. I need more coffee. I thought you were trying to emit HTML.


githree
2018-7-11 12:07:13

It was my fault - I wasn’t clear in the example above - need to edit it


blerner
2018-7-11 12:07:56

Probably a lot easier to generate an .svg file, then use @image to load it into your page


greg
2018-7-11 12:11:45

I guess it depends on your desired render targets. If just HTML, then I think somehow literal should get the &lt;svg&gt; element in the scribble-rendered HTML, and from there displaying it is up to the web browser? But if you care also/instead about PDF/LaTeX output, idk off-hand.


greg
2018-7-11 12:12:14

Or if just HTML, what @blerner said. :slightly_smiling_face:


greg
2018-7-11 12:12:36

Oh wait, I see. What @blerner said for all the cases.


githree
2018-7-11 12:13:14

I was trying to avoid generating files but at least it is some solution


greg
2018-7-11 12:14:09

greg
2018-7-11 12:14:39

(maybe some clue in its source)


githree
2018-7-11 12:17:54

thank you both - I need to go now but have also one idea I will test later with @image being backup plan


mflatt
2018-7-11 12:29:40

@githree If you want to avoid of a file, you can have a value that implements prop:convertible and supports conversion to 'svg-bytes


jeapostrophe
2018-7-11 15:20:06

@mflatt syntax/module-reader says it takes a module-path as defined by require. require says that module-path includes the submod form. But when I use that I get the error main.rkt:299:2: submod: misuse of module-path constructor (not within, e.g., `require' or `provide') in: (submod example lang)


jeapostrophe
2018-7-11 15:20:42

It’s possible that this has been updated recently, because I’m not on latest


jeapostrophe
2018-7-11 15:22:41

I just saw a message about this on the list from 2017/05/18 where you noted this and suggest using #:language


asumu
2018-7-11 18:40:15

Since @greg mentioned the rsvg library, it has a function svg-port-&gt;pict which you can pass any input port that contains an svg document and get a value that should render in scribble docs. So you should be able to just pass it a string (like your sample-svg) by using open-input-string to create an input port out of the string.


leif
2018-7-11 19:37:21

@mflatt wrt to https://github.com/racket/racket/pull/2166, were you saying that having the user pass in a #:relative-directory path for serialize is a bad idea, and its better to just have serialize use current-write-relative-directory automatically?


mflatt
2018-7-11 19:43:52

@leif For backward compatibility, I don’t think serialize should use current-write-relative-directory automatically. It makes sense to have an optional argument that is the relative-to spec; I just meant that the optional argument(s) should support a two-directory mode as well as a one-directory mode — in the same way that current-write-relative-directory has both modes.


leif
2018-7-11 19:44:22

Ah, okay, ya, that makes sense.


leif
2018-7-11 19:44:24

And it does that now.


leif
2018-7-11 19:45:15

Also one more question, I just realized that if relative-to was provided, I was converting both paths to the deserialize-id, as well as paths in the literal serialized data. I presume that’s wrong and it should only be the paths to deserialize-id, is that correct?


mflatt
2018-7-11 20:17:15

Both seem useful. Now that you point it out, I can imagine that some uses might want just or one the other.


githree
2018-7-11 21:49:56

@greg @blerner @asumu @mflatt all your suggestions were working but I wanted to test an idea and I made it work (still few things to iron out) here is what I did: xml-&gt;sxml-&gt;make-element (for entire xml tree)


sean
2018-7-12 04:49:22

@sean has joined the channel


pocmatos
2018-7-12 06:55:27

@greg you are right, completion works. Which package allows you to have a dropdown box of possibilities instead of a new buffer popup?