Re: [tw5] Re: Code Tiddler and Transclude few lines

2021-01-08 Thread Mohammad Rahmani
Hi Tones

Thank you for your feedback. Yes the idea is great to have an interactive
ui.
I also like to hear about the performance and see how I can improve the
macro hslines.


Best wishes
Mohammad


On Sat, Jan 9, 2021 at 2:25 AM TW Tones  wrote:

> Mohamad et al
>
> Nice work, I could imagine range sliders, one for the start line, one for
> the number of lines, at least for setting the "code window" to be
> displayed, at least in an authorship mode..
>
> Tones
>
> On Saturday, 9 January 2021 at 03:40:05 UTC+11 Mohammad wrote:
>
>> This *second version* of hslines even accepts a text as source code no
>> need to provide a tiddler (of course I may recommend to put your code
>> inside tiddler)
>> This can be used to teach Tiddlywiki scripts ;-)
>>
>> A minor bug is version 1 has been fixed. You can set the opacity to blur
>> the other lines .
>>
>>
>> See below examples
>>
>> [image: 497_msedge.png]
>>
>>
>> Best wishes
>> Mohammad
>>
>>
>> On Fri, Jan 8, 2021 at 7:26 PM Mohammad Rahmani 
>> wrote:
>>
>>> Attached is an interesting solution to transclude codes from a tiddler.
>>> This is useful when you want to discuss part of the code.
>>>
>>> 1. The code has a macro and a stylesheet
>>> 2. It is possible to transclude any part of code (say from line n to
>>> line m)
>>> 4. Macro accepts ALSO a composite range like "2-5, 7 9, 13-18" and *stands
>>> out* those lines no matter in what order you pass the selected range
>>> 5. The stand out lines have different background and high contrast while
>>> other parts of the code are a little faded out
>>> 6. To give a try
>>> 6.1. Download attached JSON
>>> 6.2. Drag and drop to https://tiddlywiki.com/prerelease/
>>> 6.3. Open highlight-selected-lines/test01
>>>
>>> I would like to get feedback and tell me how the efficiency can be
>>> improved.
>>>
>>> Best wishes
>>> Mohammad
>>>
>>> The macro and its sub macro is given below (
>>> highlight-selected-lines/macro)
>>>
>>> \define hslines(tid, from, to, rng, language)<$wikify name="numbers" 
>>> text=<> ><$vars length={{{ [[$to$]subtract[$from$]add[1]] }}} 
>>> ><$set name="lines" filter="[[$tid$]get[text]splitregexp[\n]addsuffix[ 
>>> ]first[$to$]last]"><$list 
>>> filter="[range[$from$,$to$,1]]" variable=num><$list 
>>> filter="[enlistnsort[]matchthen[code-selected]else[code-notselected]]"
>>>  variable=selectedClass><$vars pos={{{ [subtract[$from$]add[1]] }}} 
>>> >> ><$codeblock code={{{ 
>>> [enlist:rawnth]  }}} language=<<__language__>>/> 
>>> 
>>> \end
>>>
>>> \define rng2list() {{{[range[$(start)$,$(end)$]addsuffix[ ]]}}}
>>>
>>> \define rawlist()<$list filter="[<__rng__>split[,]split[ ]!is[blank]]" 
>>> variable=num><$list filter="[search:title[-]]" emptyMessage=<> 
>>> variable=vrng><$vars start= {{{ [split[-]first[]] }}}
>>>end=   {{{ [split[-]last[]] }}} >
>>>  <>
>>> \end
>>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to tiddlywiki+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/70637961-7433-47db-ace4-36f8fcafa869n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAAV1gMB72fVVisD8ic9ETBK-10WxbRYK%2BeZ3RN%2B2zGoT7ZEaSw%40mail.gmail.com.


Re: [tw5] Re: Code Tiddler and Transclude few lines

2021-01-08 Thread TW Tones
Mohamad et al

Nice work, I could imagine range sliders, one for the start line, one for 
the number of lines, at least for setting the "code window" to be 
displayed, at least in an authorship mode..

Tones

On Saturday, 9 January 2021 at 03:40:05 UTC+11 Mohammad wrote:

> This *second version* of hslines even accepts a text as source code no 
> need to provide a tiddler (of course I may recommend to put your code 
> inside tiddler)
> This can be used to teach Tiddlywiki scripts ;-)
>
> A minor bug is version 1 has been fixed. You can set the opacity to blur 
> the other lines .
>
>
> See below examples
>
> [image: 497_msedge.png]
>
>
> Best wishes
> Mohammad
>
>
> On Fri, Jan 8, 2021 at 7:26 PM Mohammad Rahmani  
> wrote:
>
>> Attached is an interesting solution to transclude codes from a tiddler. 
>> This is useful when you want to discuss part of the code.
>>
>> 1. The code has a macro and a stylesheet
>> 2. It is possible to transclude any part of code (say from line n to line 
>> m)  
>> 4. Macro accepts ALSO a composite range like "2-5, 7 9, 13-18" and *stands 
>> out* those lines no matter in what order you pass the selected range
>> 5. The stand out lines have different background and high contrast while 
>> other parts of the code are a little faded out
>> 6. To give a try 
>> 6.1. Download attached JSON
>> 6.2. Drag and drop to https://tiddlywiki.com/prerelease/
>> 6.3. Open highlight-selected-lines/test01
>>
>> I would like to get feedback and tell me how the efficiency can be 
>> improved. 
>>
>> Best wishes
>> Mohammad
>>
>> The macro and its sub macro is given below ( 
>> highlight-selected-lines/macro)
>>
>> \define hslines(tid, from, to, rng, language)<$wikify name="numbers" 
>> text=<> ><$vars length={{{ [[$to$]subtract[$from$]add[1]] }}} 
>> ><$set name="lines" filter="[[$tid$]get[text]splitregexp[\n]addsuffix[ 
>> ]first[$to$]last]"><$list 
>> filter="[range[$from$,$to$,1]]" variable=num><$list 
>> filter="[enlistnsort[]matchthen[code-selected]else[code-notselected]]"
>>  variable=selectedClass><$vars pos={{{ [subtract[$from$]add[1]] }}} 
>> >> ><$codeblock code={{{ 
>> [enlist:rawnth]  }}} language=<<__language__>>/> 
>> 
>> \end
>>
>> \define rng2list() {{{[range[$(start)$,$(end)$]addsuffix[ ]]}}}
>>
>> \define rawlist()<$list filter="[<__rng__>split[,]split[ ]!is[blank]]" 
>> variable=num><$list filter="[search:title[-]]" emptyMessage=<> 
>> variable=vrng><$vars start= {{{ [split[-]first[]] }}}
>>end=   {{{ [split[-]last[]] }}} >
>>  <> 
>> \end
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/70637961-7433-47db-ace4-36f8fcafa869n%40googlegroups.com.


Re: [tw5] Re: Code Tiddler and Transclude few lines

2021-01-08 Thread Mohammad Rahmani
This *second version* of hslines even accepts a text as source code no need
to provide a tiddler (of course I may recommend to put your code inside
tiddler)
This can be used to teach Tiddlywiki scripts ;-)

A minor bug is version 1 has been fixed. You can set the opacity to blur
the other lines .


See below examples

[image: 497_msedge.png]


Best wishes
Mohammad


On Fri, Jan 8, 2021 at 7:26 PM Mohammad Rahmani 
wrote:

> Attached is an interesting solution to transclude codes from a tiddler.
> This is useful when you want to discuss part of the code.
>
> 1. The code has a macro and a stylesheet
> 2. It is possible to transclude any part of code (say from line n to line
> m)
> 4. Macro accepts ALSO a composite range like "2-5, 7 9, 13-18" and *stands
> out* those lines no matter in what order you pass the selected range
> 5. The stand out lines have different background and high contrast while
> other parts of the code are a little faded out
> 6. To give a try
> 6.1. Download attached JSON
> 6.2. Drag and drop to https://tiddlywiki.com/prerelease/
> 6.3. Open highlight-selected-lines/test01
>
> I would like to get feedback and tell me how the efficiency can be
> improved.
>
> Best wishes
> Mohammad
>
> The macro and its sub macro is given below (
> highlight-selected-lines/macro)
>
> \define hslines(tid, from, to, rng, language)<$wikify name="numbers" 
> text=<> ><$vars length={{{ [[$to$]subtract[$from$]add[1]] }}} ><$set 
> name="lines" filter="[[$tid$]get[text]splitregexp[\n]addsuffix[ 
> ]first[$to$]last]"><$list 
> filter="[range[$from$,$to$,1]]" variable=num><$list 
> filter="[enlistnsort[]matchthen[code-selected]else[code-notselected]]"
>  variable=selectedClass><$vars pos={{{ [subtract[$from$]add[1]] }}} 
> >> ><$codeblock code={{{ 
> [enlist:rawnth]  }}} language=<<__language__>>/> 
> 
> \end
>
> \define rng2list() {{{[range[$(start)$,$(end)$]addsuffix[ ]]}}}
>
> \define rawlist()<$list filter="[<__rng__>split[,]split[ ]!is[blank]]" 
> variable=num><$list filter="[search:title[-]]" emptyMessage=<> 
> variable=vrng><$vars start= {{{ [split[-]first[]] }}}
>end=   {{{ [split[-]last[]] }}} >
>  <>  
> \end
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAAV1gMASCQLDR_CMWPkxvCh4jn%2Bh_Skp8cdJef4fS_kkyioJog%40mail.gmail.com.


highlight-selected-lines-v2.json
Description: application/json


Re: [tw5] Re: Code Tiddler and Transclude few lines

2021-01-08 Thread Mohammad Rahmani
Attached is an interesting solution to transclude codes from a tiddler.
This is useful when you want to discuss part of the code.

1. The code has a macro and a stylesheet
2. It is possible to transclude any part of code (say from line n to line
m)
4. Macro accepts ALSO a composite range like "2-5, 7 9, 13-18" and *stands
out* those lines no matter in what order you pass the selected range
5. The stand out lines have different background and high contrast while
other parts of the code are a little faded out
6. To give a try
6.1. Download attached JSON
6.2. Drag and drop to https://tiddlywiki.com/prerelease/
6.3. Open highlight-selected-lines/test01

I would like to get feedback and tell me how the efficiency can be
improved.

Best wishes
Mohammad

The macro and its sub macro is given below ( highlight-selected-lines/macro)

\define hslines(tid, from, to, rng, language)<$wikify name="numbers"
text=<> ><$vars length={{{ [[$to$]subtract[$from$]add[1]] }}}
><$set name="lines" filter="[[$tid$]get[text]splitregexp[\n]addsuffix[
]first[$to$]last]"><$list
filter="[range[$from$,$to$,1]]" variable=num><$list
filter="[enlistnsort[]matchthen[code-selected]else[code-notselected]]"
variable=selectedClass><$vars pos={{{ [subtract[$from$]add[1]]
}}} >> ><$codeblock code={{{
[enlist:rawnth]  }}} language=<<__language__>>/>

\end

\define rng2list() {{{[range[$(start)$,$(end)$]addsuffix[ ]]}}}

\define rawlist()<$list filter="[<__rng__>split[,]split[ ]!is[blank]]"
variable=num><$list filter="[search:title[-]]"
emptyMessage=<> variable=vrng><$vars start= {{{
[split[-]first[]] }}}
   end=   {{{ [split[-]last[]] }}} >
 <>
\end

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAAV1gMAaxTcjsKEB-mKE1rZGk1-e2%2BXFfUTsxkBfMRsR-12P8g%40mail.gmail.com.


standout-lines-of-code.json
Description: application/json


Re: [tw5] Re: Code Tiddler and Transclude few lines

2021-01-08 Thread Mohammad Rahmani
To explain the solution I just posted
The modified code is as below. The issue here is if you remove the
$codeblock and pass the whole macro output to a single $codeblock the macro
content will be displayed!
If you use the $wikify widget the line breaks will be removed. So what do
you think?

\define showLinesc(tid,from,to,language)<$vars length={{{
[[$to$]subtract[$from$]add[1]] }}}><$set name="lines"
filter="[[$tid$]get[text]splitregexp[\n]addsuffix[
]first[$to$]last]"><$list
filter="[enlist:raw]" variable="line"><$codeblock
code=<> language=<<__language__>>/>
\end

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAAV1gMAR7kOYJmxg2%3DZaELdov%3DKST%3D4W%2BscQWGhG0HQQDTv4UA%40mail.gmail.com.


Re: [tw5] Re: Code Tiddler and Transclude few lines

2021-01-08 Thread Mohammad
Hi,
I tried to implement a partial solution to transclude selected lines of 
code from a tiddler contains the whole code.
Then I transcluded the whole code with those selected lines. The whole code 
is opaque but those lines are clear with sharp contrast.
This way one can show a code with few lines stand out to get the viewer 
attention.

To give a try 
1. download attached example, 
2. drop on https://tiddlywiki.com/prerelease/   (use prerelease which has 
the Highlight.js installed)
3.  open test/code-lines  and see how the code looks like

You can do more examples by opening  test/code-lines  and editing the lines.

*Note*: I am not happy with this solution, it seems a little tedious and 
low in performance (a lot of  tags are created. What is the 
better solution.



On Friday, January 8, 2021 at 11:10:31 AM UTC+3:30 Mohammad wrote:

> Hi Eric,
>
>  I came to this thread and found it very interesting. One use case is to 
> show a code using the $codeblock widget with language to highlight the code 
> for those specified lines and show the rest without highlighting!
>
>  I appreciate to instruct me how to do this. I thought to use the 
> $codeblock widget instead of pre tag in showLines but this way I see 
> fragmented output.
>  
>
> Best wishes
> Mohammad
>
>
> On Thu, Nov 26, 2020 at 3:35 AM Eric Shulman  wrote:
>
>> On Wednesday, November 25, 2020 at 3:19:13 PM UTC-8 TW Tones wrote:
>>
>>>
>>>- And perhaps a code view with line numbers from the source.
>>>
>>>
>> Here's an updated version that add line numbers AND also fixes a bug 
>> whereby only one blank line was included in the output
>>
>> \define showLines(tid,from,to)
>> <$vars length={{{ [[$to$]subtract[$from$]add[1]] }}}>
>> <$set name="lines" filter="[[$tid$]get[text]splitregexp[\n]addsuffix[ 
>> ]first[$to$]last]">
>> <$list filter="[enlist:raw]" 
>> variable="line"><$text text=<>/>
>> 
>> 
>> \end
>>  
>> Notes:
>> * The $set filter adds a space to end of each line.  This effectively 
>> preserves multiple blank lines by making them non-empty list items
>> * The output is wrapped in ... and uses 
>> ...  instead of a trailing  to add the line numbers
>>
>> enjoy,
>> -e
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "TiddlyWiki" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to tiddlywiki+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/tiddlywiki/f609beb5-695f-4b38-aff3-36afe498cde9n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/49fe773f-bb0e-4389-beb2-f5a4579d642an%40googlegroups.com.


standout-lines-of-code.json
Description: application/json


Re: [tw5] Re: Code Tiddler and Transclude few lines

2021-01-07 Thread Mohammad Rahmani
Hi Eric,

 I came to this thread and found it very interesting. One use case is to
show a code using the $codeblock widget with language to highlight the code
for those specified lines and show the rest without highlighting!

 I appreciate to instruct me how to do this. I thought to use the
$codeblock widget instead of pre tag in showLines but this way I see
fragmented output.


Best wishes
Mohammad


On Thu, Nov 26, 2020 at 3:35 AM Eric Shulman  wrote:

> On Wednesday, November 25, 2020 at 3:19:13 PM UTC-8 TW Tones wrote:
>
>>
>>- And perhaps a code view with line numbers from the source.
>>
>>
> Here's an updated version that add line numbers AND also fixes a bug
> whereby only one blank line was included in the output
>
> \define showLines(tid,from,to)
> <$vars length={{{ [[$to$]subtract[$from$]add[1]] }}}>
> <$set name="lines" filter="[[$tid$]get[text]splitregexp[\n]addsuffix[
> ]first[$to$]last]">
> <$list filter="[enlist:raw]"
> variable="line"><$text text=<>/>
> 
> 
> \end
>
> Notes:
> * The $set filter adds a space to end of each line.  This effectively
> preserves multiple blank lines by making them non-empty list items
> * The output is wrapped in ... and uses
> ...  instead of a trailing  to add the line numbers
>
> enjoy,
> -e
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to tiddlywiki+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/f609beb5-695f-4b38-aff3-36afe498cde9n%40googlegroups.com
> 
> .
>

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


[tw5] Re: Code Tiddler and Transclude few lines

2020-11-25 Thread TW Tones
Eric,

Very impressive Thanks.

I am playing with further extension's. Love it.

Tones

On Thursday, 26 November 2020 at 11:21:02 UTC+11 Eric Shulman wrote:

> On Wednesday, November 25, 2020 at 3:19:13 PM UTC-8 TW Tones wrote:
>
>>
>>- It would be nice to extend this also to a wikified version as well. 
>>
>>
> Wikified output should be as simple as changing this line:
> <$list filter="[enlist:raw]" variable="line"><$text 
> text=<>/>  
> to:
> <$list filter="[enlist:raw]" variable="line"><>
>
> (i.e., remove the  wrapper and the use of the $text widget)
>
> -e
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/75a23f0f-1de4-4677-b0b8-c24ad0d86380n%40googlegroups.com.


[tw5] Re: Code Tiddler and Transclude few lines

2020-11-25 Thread Eric Shulman
On Wednesday, November 25, 2020 at 3:19:13 PM UTC-8 TW Tones wrote:

>
>- It would be nice to extend this also to a wikified version as well. 
>
>
Wikified output should be as simple as changing this line:
<$list filter="[enlist:raw]" variable="line"><$text 
text=<>/>  
to:
<$list filter="[enlist:raw]" variable="line"><>

(i.e., remove the  wrapper and the use of the $text widget)

-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/03ed6001-f77f-40ac-83a5-85bd7cb6eb81n%40googlegroups.com.


[tw5] Re: Code Tiddler and Transclude few lines

2020-11-25 Thread Eric Shulman
On Wednesday, November 25, 2020 at 3:19:13 PM UTC-8 TW Tones wrote:

>
>- And perhaps a code view with line numbers from the source.
>
>
Here's an updated version that add line numbers AND also fixes a bug 
whereby only one blank line was included in the output

\define showLines(tid,from,to)
<$vars length={{{ [[$to$]subtract[$from$]add[1]] }}}>
<$set name="lines" filter="[[$tid$]get[text]splitregexp[\n]addsuffix[ 
]first[$to$]last]">
<$list filter="[enlist:raw]" 
variable="line"><$text text=<>/>


\end
 
Notes:
* The $set filter adds a space to end of each line.  This effectively 
preserves multiple blank lines by making them non-empty list items
* The output is wrapped in ... and uses ...  
instead of a trailing  to add the line numbers

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f609beb5-695f-4b38-aff3-36afe498cde9n%40googlegroups.com.


[tw5] Re: Code Tiddler and Transclude few lines

2020-11-25 Thread TW Tones
Eric/ Atronoush

Eric, I really like that. Just some thoughts as a result.

   - It would be nice to extend this also to a wikified version as well. 
   - And perhaps a code view with line numbers from the source.
   - Perhaps a tool for selecting the start and end lines in the source 
   tiddler would be cool


Atronoush 

   - I imagine your code tiddler has a different "type" field set,  also 
   you are using codemirror because its editor lists line numbers.
   - There are code highlighters available as well in tiddlywiki

Regards
Tones

On Thursday, 26 November 2020 at 09:26:14 UTC+11 Eric Shulman wrote:

> Place the following in a tiddler (e.g., "ShowLinesMacro"), tagged with 
> $:/tags/Macro"
> \define showLines(tid,from,to)
> <$vars length={{{ [[$to$]subtract[$from$]add[1]] }}}>
> <$set name="lines" 
> filter="[[$tid$]get[text]splitregexp[\n]first[$to$]last]">
> <$list filter="[enlist:raw]" variable="line"><$text 
> text=<>/>
> 
> 
> \end
>
> which can then be invoked using:
> <>
> 
> <>
>
> enjoy,
> -e
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/b5962cb3-2842-4d02-bd2f-88eb7d159caen%40googlegroups.com.


[tw5] Re: Code Tiddler and Transclude few lines

2020-11-25 Thread Atronoush
Thank you Eric!

Works like a charm!

-Atro

On Thursday, November 26, 2020 at 1:56:14 AM UTC+3:30 Eric Shulman wrote:

> Place the following in a tiddler (e.g., "ShowLinesMacro"), tagged with 
> $:/tags/Macro"
> \define showLines(tid,from,to)
> <$vars length={{{ [[$to$]subtract[$from$]add[1]] }}}>
> <$set name="lines" 
> filter="[[$tid$]get[text]splitregexp[\n]first[$to$]last]">
> <$list filter="[enlist:raw]" variable="line"><$text 
> text=<>/>
> 
> 
> \end
>
> which can then be invoked using:
> <>
> 
> <>
>
> enjoy,
> -e
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/e3cb3461-4555-49fa-a047-f2c0ca019cean%40googlegroups.com.


[tw5] Re: Code Tiddler and Transclude few lines

2020-11-25 Thread Eric Shulman
Place the following in a tiddler (e.g., "ShowLinesMacro"), tagged with 
$:/tags/Macro"
\define showLines(tid,from,to)
<$vars length={{{ [[$to$]subtract[$from$]add[1]] }}}>
<$set name="lines" 
filter="[[$tid$]get[text]splitregexp[\n]first[$to$]last]">
<$list filter="[enlist:raw]" variable="line"><$text 
text=<>/>


\end

which can then be invoked using:
<>

<>

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/fe41d109-4bf4-40a6-8a25-15505d52ed5an%40googlegroups.com.


[tw5] Re: Code Tiddler and Transclude few lines

2020-11-25 Thread Atronoush
See also this discussion for possible solution
https://groups.google.com/forum/#!topic/tiddlywiki/6eL-yh2qdB8

On Thursday, November 26, 2020 at 1:07:43 AM UTC+3:30 Atronoush wrote:

> Correction:
>
> Then in another tiddler I explain how code works and I need to include few 
> *lines* of code and explain them. So for example in Tiddler B, I need to 
> transclude *lines 3-5* and in another part transclude *lines 8-19 * 
>
> On Thursday, November 26, 2020 at 1:05:46 AM UTC+3:30 Atronoush wrote:
>
>> I use a Tiddlywiki for my Python codes. So I have a tiddler like below
>>
>> Title: Slab Catalyst
>> Body:
>>  # Problem data and parameters
>> L= 1e-3# pellet thickness, m
>> Cao=0.2# concen at the surface, kg-mol/m3
>> k=1e-3 # reaction rate constant, 1/s
>> Dab=1.2e-9 # diffusion coeff, m2/s
>>
>> # Calculate Thiele modulus
>> phi=L * np.sqrt(k/Dab)
>> 
>> def slab_exact(z):
>> """ dcalculates the exact solution """
>> x = 1 - z/L
>> Ca=Cao*np.cosh(phi*x)/np.cosh(phi)
>> return Ca
>>
>> def odefun(z,u):
>> """ defines the set of odes """
>> u1, u2 = u
>> dudz=[ u2,
>>k/Dab*u1 ]
>> return dudz
>> 
>> def bcfun(ul, ur):
>> """ defines the boundary conditions """
>> residue=[ ul[0]-Cao,
>>   ur[1] ]
>> return residue
>>
>> Then in another tiddler I explain how code works and I need to include 
>> few line of code and explain them. So for example in Tiddler B, I need to 
>> transclude like 3-5 and in another part transclude like 8-19
>>
>> Using the Tiddlywiki filter operators it possible to process a tiddler 
>> contents and break into lines, I wish to have a macro able
>> transclude certain lines of code in another tiddler.
>>
>> -Atro
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8aad9453-0034-4c3e-898e-c364da864e2fn%40googlegroups.com.


[tw5] Re: Code Tiddler and Transclude few lines

2020-11-25 Thread Atronoush
Correction:

Then in another tiddler I explain how code works and I need to include few 
*lines* of code and explain them. So for example in Tiddler B, I need to 
transclude *lines 3-5* and in another part transclude *lines 8-19 * 

On Thursday, November 26, 2020 at 1:05:46 AM UTC+3:30 Atronoush wrote:

> I use a Tiddlywiki for my Python codes. So I have a tiddler like below
>
> Title: Slab Catalyst
> Body:
>  # Problem data and parameters
> L= 1e-3# pellet thickness, m
> Cao=0.2# concen at the surface, kg-mol/m3
> k=1e-3 # reaction rate constant, 1/s
> Dab=1.2e-9 # diffusion coeff, m2/s
>
> # Calculate Thiele modulus
> phi=L * np.sqrt(k/Dab)
> 
> def slab_exact(z):
> """ dcalculates the exact solution """
> x = 1 - z/L
> Ca=Cao*np.cosh(phi*x)/np.cosh(phi)
> return Ca
>
> def odefun(z,u):
> """ defines the set of odes """
> u1, u2 = u
> dudz=[ u2,
>k/Dab*u1 ]
> return dudz
> 
> def bcfun(ul, ur):
> """ defines the boundary conditions """
> residue=[ ul[0]-Cao,
>   ur[1] ]
> return residue
>
> Then in another tiddler I explain how code works and I need to include few 
> line of code and explain them. So for example in Tiddler B, I need to 
> transclude like 3-5 and in another part transclude like 8-19
>
> Using the Tiddlywiki filter operators it possible to process a tiddler 
> contents and break into lines, I wish to have a macro able
> transclude certain lines of code in another tiddler.
>
> -Atro
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f1899d08-956b-4025-be6f-edc09e5123f4n%40googlegroups.com.