Re: [racket-users] suppressing scribble-common.js in Scribble output

2020-07-02 Thread Matthew Flatt
I don't know if there's a way to suppress "scribble-common.js" except
at the level of the rendering object --- that is, not something that
can be done within the document, currently. Also, the initialization
arguments that would replace "scribble-common.js" are probably not
documented. There's a lot of room for improvement there.

But you can add more JS after the built-in pieces: A
`js-style-addition` as a style property specifies JS to load after
other things.

At Thu, 2 Jul 2020 20:09:53 -0700 (PDT), Shriram Krishnamurthi wrote:
> How does one suppress scribble-common.js? I really don't understand why the 
> file loads for all Scribble langs — it contains things like search box 
> support for documentation! 
> 
> In addition, it takes over the window.onload, overriding any previous 
> content. About this, it has the following odd remark:
> 
> // Note: could make a function that inspects and uses window.onload to 
> chain to
> // a previous one, but this file needs to be required first anyway, since it
> // contains utilities for all other files.
> 
> I'm not sure what "all other files" it's referring to, but it actually 
> appears *last* in the load sequence. (E.g., loading additional JS through a 
> custom prefix means those get loaded before scribble-common.js…is there 
> some other way of loading JS files so they are loaded *after*
>  scribble-common.js?)
> 
> Shriram
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/e219a0cd-7646-4bdf-a620-ac0d70f3
> 8cceo%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200702212417.152%40sirmail.smtp.cs.utah.edu.


Re: [racket-users] suppressing parts of Scribble (HTML) output

2020-07-02 Thread Shriram Krishnamurthi
Oh my gosh, this is *exactly* what I need! Thank you!!!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAJUf2yQiH-3E9yDhbb693vc-EUKMf2vG8i4mZ_B7LhWnYtnwOA%40mail.gmail.com.


[racket-users] suppressing scribble-common.js in Scribble output

2020-07-02 Thread Shriram Krishnamurthi
How does one suppress scribble-common.js? I really don't understand why the 
file loads for all Scribble langs — it contains things like search box 
support for documentation! 

In addition, it takes over the window.onload, overriding any previous 
content. About this, it has the following odd remark:

// Note: could make a function that inspects and uses window.onload to 
chain to
// a previous one, but this file needs to be required first anyway, since it
// contains utilities for all other files.

I'm not sure what "all other files" it's referring to, but it actually 
appears *last* in the load sequence. (E.g., loading additional JS through a 
custom prefix means those get loaded before scribble-common.js…is there 
some other way of loading JS files so they are loaded *after*
 scribble-common.js?)

Shriram

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/e219a0cd-7646-4bdf-a620-ac0d70f38cceo%40googlegroups.com.


Re: [racket-users] suppressing parts of Scribble (HTML) output

2020-07-02 Thread Matthew Flatt
Does the `'no-toc+aux` style property help at all? For example,

  #lang scribble/manual

  @title[#:style '(no-toc+aux)]{Example}

  Some content.

should render with nothing on the left.

At Thu, 2 Jul 2020 18:47:19 -0700 (PDT), Shriram Krishnamurthi wrote:
> I am trying to use Scribble to generate HTML documents (blog-like, but not 
> exactly, so Frog doesn't meet my needs) but would really like to eliminate 
> the material in the left gutter (TOC). (Ideally I'd also like to suppress 
> the author tag.)
> 
> I've spent some time going through the source of Greg Hendershott's Frog 
> and Ryan Culpepper's Scriblogify and both seem to use essentially the same 
> technique, which is a total hack: call Scribble to generate the HTML, then 
> go into it and search for a particular DOM structure to extract the "main 
> content". For instance, Scriblogify does this
> 
> (define (get-blog-entry file)
> 
>   (let* ([doc (call-with-input-file file html->xexp)]
> 
>  [title ((sxpath "//title/text()") doc)]
> 
>  [title (and (pair? title) (car title))]
> 
>  [content
> 
>   ((sxpath 
> "//div[@class='SAuthorListBox']/following-sibling::node()") doc)]
> 
> while Frog does
> 
>   ;; Extract the part we care about -- the elements in the "main" div
> 
>   ;; after the "versionbox" div.  (The `match` might be too fragile
> 
>   ;; way to do this.)
> 
>   (match (~> (build-path dir "frog.html")
> 
>  (with-input-from-file read-html-as-xexprs)
> 
>  cadr)
> 
> ; HTML produced from #scribble/manual
> 
> [`(html
> 
>()
> 
>(head . ,_)
> 
>,(list-no-order
> 
>  `(div ([class "maincolumn"])
> 
>(div ([class "main"])
> 
> (div ([class "versionbox"])
> 
>  (span ([class "versionNoNav"]) ,_))
> 
> . ,xs))
> 
>  _ ...))
> 
>  (adjust-scribble-html xs img-uri)]
> 
> (it actually has different patterns depending on the Scribble language 
> used!).
> 
> What's a better, cleaner way of doing this? I *suppose* one could build a 
> whole renderer, which seems like an insane amount of work. Hopefully 
> there's a way of doing this as a "delta" on the existing renderer, but I 
> haven't had any luck finding an example of a custom renderer that, say, 
> suppresses the printing of the TOC and/or the author list but leaves the 
> rest of the page alone.
> 
> [Yes, I could set up the CSS so that the TOC appears hidden, but it would 
> still be present in the source and could be found by one of several means. 
> I would really like it to not be there. And I hope there's a better way of 
> doing it than modifying the JavaScript to, on load, go and delete the 
> undesired elements…]
> 
> Any ideas/suggestions/pointers? Thanks!
> 
> Shriram
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/246966eb-3521-40fe-93c5-b4bf6a81
> 379eo%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200702210047.d9%40sirmail.smtp.cs.utah.edu.


[racket-users] suppressing parts of Scribble (HTML) output

2020-07-02 Thread Shriram Krishnamurthi
I am trying to use Scribble to generate HTML documents (blog-like, but not 
exactly, so Frog doesn't meet my needs) but would really like to eliminate 
the material in the left gutter (TOC). (Ideally I'd also like to suppress 
the author tag.)

I've spent some time going through the source of Greg Hendershott's Frog 
and Ryan Culpepper's Scriblogify and both seem to use essentially the same 
technique, which is a total hack: call Scribble to generate the HTML, then 
go into it and search for a particular DOM structure to extract the "main 
content". For instance, Scriblogify does this

(define (get-blog-entry file)

  (let* ([doc (call-with-input-file file html->xexp)]

 [title ((sxpath "//title/text()") doc)]

 [title (and (pair? title) (car title))]

 [content

  ((sxpath 
"//div[@class='SAuthorListBox']/following-sibling::node()") doc)]

while Frog does

  ;; Extract the part we care about -- the elements in the "main" div

  ;; after the "versionbox" div.  (The `match` might be too fragile

  ;; way to do this.)

  (match (~> (build-path dir "frog.html")

 (with-input-from-file read-html-as-xexprs)

 cadr)

; HTML produced from #scribble/manual

[`(html

   ()

   (head . ,_)

   ,(list-no-order

 `(div ([class "maincolumn"])

   (div ([class "main"])

(div ([class "versionbox"])

 (span ([class "versionNoNav"]) ,_))

. ,xs))

 _ ...))

 (adjust-scribble-html xs img-uri)]

(it actually has different patterns depending on the Scribble language 
used!).

What's a better, cleaner way of doing this? I *suppose* one could build a 
whole renderer, which seems like an insane amount of work. Hopefully 
there's a way of doing this as a "delta" on the existing renderer, but I 
haven't had any luck finding an example of a custom renderer that, say, 
suppresses the printing of the TOC and/or the author list but leaves the 
rest of the page alone.

[Yes, I could set up the CSS so that the TOC appears hidden, but it would 
still be present in the source and could be found by one of several means. 
I would really like it to not be there. And I hope there's a better way of 
doing it than modifying the JavaScript to, on load, go and delete the 
undesired elements…]

Any ideas/suggestions/pointers? Thanks!

Shriram

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/246966eb-3521-40fe-93c5-b4bf6a81379eo%40googlegroups.com.


[racket-users] Re: Quickscript Competition

2020-07-02 Thread Stephen De Gabrielle
*Need some ideas?  *Check out some examples from quickscript-extra 
, and some starter ideas 
below.

Ideas
   
   - csv->sexp or json->sexp (use existing libraries)
   - sort a list of numbers from the selection
   - lexer with split string
   - spell check or spelling fixer (more complicated)
   - beautify code (using pretty-print for example)
   - ASCII art !
   - Add Windows and/or Macos support to *git 
   *. 
   (maybe use open-terminal 
   

 as 
   a starting point?)
   - Post the current selection to the Racket Slack. (*tweet 
   
* 
is 
   an example of using a web api)
   - Make a game? (maybe use 2htdp/universe 
    or lux 
   ?)

*Looking for more ideas?* What about porting some of emacs scripts 
 and vim scripts 
?

When you have an idea...Getting started for the impatient 

 is 
a good starting point.

*Some existing examples*

   - *abstract-variable 
   
*:
 
   Create a variable from the selected expression video 
   
   - *extract-function 
   
*:
 
   Extracts a block of code out of its context and generates a function and a 
   call video 
   - *indent-table 
   
*:
 
   Indent rows on double-space-separated colums video 
   

*Win Prizes and the Admiration of your peers.*

Good Luck & Have fun

Stephen

PS a ROT13 encoder/decoder was the first entry!

On Wednesday, July 1, 2020 at 11:03:02 AM UTC+1 Stephen De Gabrielle wrote:

> *Quickscript Competition:*
>
> Quickscript  is the scripting 
> functionality behind the DrRacket Scripts menu:
>
> For the month of July we will be running a Quickscript competition: Write 
> your own script and win prizes! There will be weekly winners in categories 
> to be determined by the judges and overall awards at the end of the month. 
>
> We follow Racket's and the ACM's Code of Conduct 
> .
>
> *There
>  
> will be amazing prizes!*
>
>- An exclusive badge for your github profile recognising your efforts 
>and contribution to the community.
>- Socks/Mugs/Hats/Stickers with the Racket logo - to be announced on 
>Racket Users mailing list/google group.
>
> Scripts licensed appropriately will be included in a package for 
> installation and universal fame.
>
> End date: 31-July
> *Getting started*
>
> Getting started for the impatient 
> 
>  in 
> DrRacket.
>
> See quickscript-extra [readme 
> ] [
> scripts ] 
> for a bunch of useful and example scripts.
>
> Help and discussion will be available through the #quickscript-competition 
>  slack channel.
>
> *Once your script is ready, submit your entry 
> !*
>
> Need
>  
> some *ideas to get started* 
> 
> ?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ff3eac01-f6d3-410b-b14b-e1974479c2e5n%40googlegroups.com.


Re: [racket-users] Wills, plumbers, and checking if a port is closed

2020-07-02 Thread David Storrs
Doh, just realized I never responded to this. Thank you guys so much. As
always, it's really appreciated.

On Tue, Jun 30, 2020, 7:21 PM Ryan Culpepper  wrote:

> Here's a function that creates a thread that waits until a port is closed
> and then prints a message:
>
>   (define (watch-for-port-close p)
> (thread (lambda () (sync (port-closed-evt out)) (eprintf "port
> closed\n"
>
> For example:
>
>   (define out (open-output-string))
>   (watch-for-port-close out) ;; => #
>   (close-output-port out) ;; prints "port closed"
>
> One reason a port can get closed is because of a custodian shutdown, and
> in that case you'd need to make sure that the watcher thread and its
> current-error-port are not managed by the same custodian. Here's a version
> that creates an unkillable thread (generally a bad idea, but probably okay
> for debugging):
>
>   (require ffi/unsafe/custodian)
>   (define (watch-for-port-close p)
> (parameterize ((current-custodian (make-custodian-at-root)))
>   (thread (lambda () (sync (port-closed-evt out)) (eprintf "port
> closed\n")
>
> Ryan
>
> On Wed, Jul 1, 2020 at 1:08 AM Matthew Flatt  wrote:
>
>> At Tue, 30 Jun 2020 16:27:56 -0400, David Storrs wrote:
>> > I have a port that (my current theory says) is being closed when it
>> > shouldn't, but I'm having trouble isolating exactly where and when.  I
>> > thought maybe I could do something Rackety to say "as soon as this port
>> > gets closed, run this function".  I went digging through Wills and
>> Plumbers
>> > but I'm having trouble grokking it.  Am I headed in the right
>> direction, or
>> > is there a better way?
>>
>> Wills and plumbers will not help.
>>
>> Do you have control over where the port is used to that you can
>> substitute another port? In that case, you could wrap the port with
>> `make-input-port` or `make-output-port`, and then you have control over
>> the close method.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/20200630164403.17c%40sirmail.smtp.cs.utah.edu
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKoe%3D5rVWODw848kta9dfz-KGNgTeP5UMCPTPSso0WhwcTw%40mail.gmail.com.