Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOC #67

Open
gedw99 opened this issue Mar 6, 2025 · 6 comments
Open

TOC #67

gedw99 opened this issue Mar 6, 2025 · 6 comments

Comments

@gedw99
Copy link

gedw99 commented Mar 6, 2025

Cant seem to get TOC working with the mdtopdf

The links ( the TOC ones ) in the final PDF try to open a new page in Mac PDF native viewer..

See the see attachments...

test_all.md
test_all.md.pdf

I slap it into the test_all.md and then:

md2pdf_bin_darwin_arm64 -title "test title" -author "Gerard Webb" --page-size A4 -i /Users/apple/workspace/go/src/github.com/gedw99/kanka-cloudflare/projects/dickson/.src/dickson/test_all.md --theme /Users/apple/workspace/go/src/github.com/gedw99/kanka-cloudflare/projects/dickson/../../modules/.dep/md2pdf_dark_theme.json -with-footer  -log-file /Users/apple/workspace/go/src/github.com/gedw99/kanka-cloudflare/projects/dickson/pdf.log -o /Users/apple/workspace/go/src/github.com/gedw99/kanka-cloudflare/projects/dickson/.src/dickson/test_all.md.pdf

I gen a TOC off the MD using https://github.com/ekalinin/github-markdown-toc.go

I get this back:

Table of Contents
=================

* [Spec and Options](#spec-and-options)
  * [Auth / Authz](#auth--authz)
  * [Chronically per environment](#chronically-per-environment)
* [Global LB Options / Prototyping](#global-lb-options--prototyping)

The final markdown

# Spec and Options


Table of Contents
=================

* [Spec and Options](#spec-and-options)
  * [Auth / Authz](#auth--authz)
  * [Chronically per environment](#chronically-per-environment)
* [Global LB Options / Prototyping](#global-lb-options--prototyping)



What I often see and do:

## Auth / Authz 

NATS Auth Callout for all OIDC systems to interoperate with NATS.

NATS nKey at runtime for real time minting of Security keys against: Sys, Org, User, Apps.

All data at Rest is encrypted against these keys.

Provides complete multi tenancy security, data and processing.

Vault for base keys, or whatever HMI you use thats conformant to Hashicorp Vault.


## Chronically per environment

The whole global system runs on a laptop with no docker needed.

The tooling will check and / or install:

1. A NATS Cluster somewhere / anywhere. 

2. A golang compiler.

3. Our Dev Ops tooling.

DEV / CI / CD / PROD is 100% identical.


# Global LB Options / Prototyping

Prototype each with main.go with health and tofu in CI / CD...

Options for Scale out of Network using traditional HTTP / SSE without NATS.

NATS Client has its own LB, but thats useless for a Browser.

1. CF --> each of my DC --> Origin Caddy --> Each of my Servers.

2. CF --> each of my DC --> Origin Caddy & CF Tunnel --> Each of my Servers

https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/configure-tunnels/tunnel-availability/#cloudflared-replicas

"By design, replicas do not offer any level of traffic steering (random, hash, or round-robin). Instead, when a request arrives to Cloudflare, it will be forwarded to the replica that is geographically closest."


3. CF --> Each of my Servers ( in all DC), running CF tunnel. NO CADDY at all.

Will have to pay for CF LB i think.

https://developers.cloudflare.com/waf/

https://dash.cloudflare.com/7384af54e33b8a54ff240371ea368440/ubuntusoftware.net/traffic/load-balancing


4. Custom use CF workers 

Also we can do custom LB using Workers running in CF:

https://blog.cloudflare.com/update-response-headers-on-cloudflare-workers/

https://aggregations.io/blog/load-balancing-data-ingest-cloudflare-workers

Gives custom routing to many places to inside CF and to our Origins.

I think this will be the winner !! Its like a Service worker in a browser, but in each CF Origin worker.

I like the parity..

5. NO Cloudflare. As we always design for self sovereignty also.

Web / Native / CLI clients are globally Load Balanced using DNS in CF or anywhere.

https://www.cloudflare.com/en-au/learning/performance/what-is-dns-load-balancing/

The DNS is setup with all the Origin IP addresses.

IN this case Option 1 using Caddy will work for HTTP and SSE.

And Custom CF worker routing is replaced by Benthos.

@jessp01
Copy link
Collaborator

jessp01 commented Mar 6, 2025

Hi @gedw99 ,

I ran this command:

md2pdf -title "test title" \
-author "Gerard Webb" --page-size A4 \
 -i https://github.com/user-attachments/files/19100608/test_all.md \
 -with-footer  -log-file pdf.log \
--theme /usr/share/mdtopdf/dark_theme.json -o test_all.md.pdf

Attached is the resulting PDF.

test_all.md.pdf

@gedw99
Copy link
Author

gedw99 commented Mar 6, 2025

It’s works in terms of producing a pdf , but did you try clicking a link in the TOC ?

The stated issues is that:

“The links ( the TOC ones ) in the final PDF try to open a new page in Mac PDF native viewer..”

It’s not working :)

It’s likely an issue with the way TOC produces the markdown .

@jessp01
Copy link
Collaborator

jessp01 commented Mar 6, 2025

It’s works in terms of producing a pdf , but did you try clicking a link in the TOC ?

Yes. As I wrote:

Attached is the resulting PDF and the links under Table of Contents all work (of course, GH gives me HTTP 404, probably because the repos are private but - clicking on them does trigger the opening of the default browser with the correct URL).

Clicking works. It does not work with the example you've uploaded, but the PDF I uploaded works fine in all my PDF viewers.

@gedw99
Copy link
Author

gedw99 commented Mar 6, 2025

mhhh.. strange indeed.

With your PDF, when I click a TOC item, it's tries to open a link via the browser. This is the MAC viewer. It should not do that.

This is exactly the same as what my pdf also does.

I have other golang software that builds PDF's, and the links in the PDF work properly in that when you click them it goes to go to another part of the same document, which is the correct way for a TOC.

I suspect that the way the TOC is generated is wrong. But not sure yet..

@gedw99
Copy link
Author

gedw99 commented Mar 6, 2025

When I click a TOC item form your PDF.

Image

@jessp01
Copy link
Collaborator

jessp01 commented Mar 6, 2025

With your PDF, when I click a TOC item, it's tries to open a link via the browser. This is the MAC viewer. It should not do that.

I use Linux exclusively, so, couldn't test on Mac even if I wanted to, but this really isn't to do with what OS or viewer you use.

In the case of the PDF I generated and shared, it tries to open external links, relative to the MD because, as I wrote in my initial comment, I've used the remote URL to the MD (-i https://github.com/user-attachments/files/19100608/test_all.md) so, the links it produces are relative to that, for example "https://github.com/user-attachments/files/19100608/#auth--authz", which, obviously, will not work.

This is exactly the same as what my pdf also does.

Well, no, the PDF you've shared, because you've not used a remote URL as the argument for -i, does not attempt to open a browser for me but it also does not "jump" to the header you linked to; to wit: clicking on the Chronically per environment
will not move focus to that header in the PDF document (as it would behave when loading https://github.com/user-attachments/files/19100608/test_all.md in a browser).

That is not currently supported. As the README states, md2pdf makes use of fpdf to generate the PDF. I am not sure fpdf supports that functionality but I can take a look at a later date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants