sethyuan / logseq-plugin-tocgen

Generate a TOC of any page anywhere to quickly access the page's content.
MIT License
144 stars 10 forks source link

[feature request]new Option:Show The First Line of a Heading #8

Closed cloudrflight closed 2 years ago

cloudrflight commented 2 years ago

Have a look at this ex. below:

- # A Heading
version:: A
type:: book
price:: ff
some describe of A heading
  - ## B heading
  - ## C heading

use tocgen plugin code ' {{renderer :tocgen , [[my page]],6,h }}',become to this:

↓A Heading version:: A
type:: book
price:: ff
some describe of A heading
   ↓B heading
   ↓C heading

actually,I want to show that like this:

↓A Heading version:: A
   ↓B heading
   ↓C heading

So,I'd like to request to show only'the first line'

sethyuan commented 2 years ago

Are you using the latest version of the plugin? Currently, block properties are removed from the content, so, the latest plugin would show something like this:

image

It's not quite what you want, but I don't think block properties should be displayed in title, what I can do, is to only use the first line of content (without block property) as title. What do you think?

sethyuan commented 2 years ago

I built a new version with this behavior. That is, only use the first line as title.

cloudrflight commented 2 years ago

I built a new version with this behavior. That is, only use the first line as title.

That's exactly what I need(v1.6.0) , Thx a lot!

By the way,I'm coming to a new problem,My note use datomic like

cloudrflight commented 2 years ago

I use a lot datomic advance queries to organize my page view like (get all feathers in last 10 day)

↓A Heading
#+BEGIN_QUERY
{
    :query
    [
        :find(pull  ?b [ *])        
     :where
            [?b :block/page ?p]
            [?p :block/properties ?prop]
            [(get ?prop :type) ?v]
            (or [(= ?v "feather")] [(contains? ?v "feather")])
            [(get ?prop :created-at) ?ti]
            [(>= ?ti 20220101)]
            [(<= ?ti 20220112)]
    ]

 }
#+END_QUERY
↓B heading
↓C heading

Preview like:

↓A Heading
    ↓D Heading
↓B heading
↓C heading

Could I request a new feature for showing the heading in the queries?

sethyuan commented 2 years ago

Can you elaborate? You want the query result be part of the TOC?

cloudrflight commented 2 years ago

Can you elaborate? You want the query result be part of the TOC?

Yes,I want to build outline of "my page" , "my page" made by a queries of many pages ,not a single [[page]];

for ex:

title:: my page
- A Heading
#+BEGIN_QUERY
{
    :query
    [
        :find(pull  ?b [ *])        
     :where
            [?b :block/page ?p]
            [?p :block/properties ?prop]
            [(get ?prop :type) ?v]
            (or [(= ?v "feather")] [(contains? ?v "feather")])
            [(get ?prop :created-at) ?ti]
            [(>= ?ti 20220101)]
            [(<= ?ti 20220112)]
    ]
 }
#+END_QUERY
- B Heading
- C Heading

and preview is:

- # A Heading
2 results
Table view   |    Set properties
    - ## Book 'herrypotter'
    blablabla..........
    - ## Book 'King of Lord'
    blablabla.........
- # B Heading
- # C Heading

I want toc to show:

↓A Heading
    ↓Book 'herrypotter'
    ↓Book 'King of Lord'
↓B Heading
↓C Heading
sethyuan commented 2 years ago

Interesting, I'm not sure if this is appropriate to do though. I think it's better to have another plugin to pull query results into the current page, then use tocgen to generate TOC as would normally do. Processing of query results shouldn't be part of a plugin like this.