npm package: @mp5maker/camfsp
Description: This will combine all the markdown in a specific folder to a single PDF
Author: Shabuktagin Photon Khan
Latest version: 1.0.43

# Combine all markdowns in a folder to a single pdf (camfsp)

This will combine all the markdown in a specific folder to a single PDF

- Just mention the folder, it will recursively select all the markdowns file with (.md) extension only
- Node.js (ESM and CommonJS) - 18.x, 19.x, 20.x

## How to use

```bash
npx @mp5maker/camfsp convert --input [folder-src] --output [file-name]
```

---

> [!CAUTION]
> Sometimes npx do not have the share module

- Windows
  - For windows machine, use git-bash or similar
- Linux

> [!TIP]
> Please use the installation process instead, if direct npx do not work

> [!CAUTION]
> Try to avoid node_modules folder

#### Installation

```bash
npm install @mp5maker/camfsp
```

#### Add it to the scripts (package.json)

```json
"generate": "npx @mp5maker/camfsp convert --input [folder-src] --output [file-name]"
```

- It can be any script name (up to you)

#### Run the script

```bash
npm run generate
```

- npm run [your-script-name]

---

## Example: Convert

- Available Options:

  - input (Required): Folder name
  - output (Required): File name (".pdf")
  - extension (Optional): pdf option will combine all pdfs to one pdf

- If your terminal is in root folder

```
npx @mp5maker/camfsp convert --input src --output documents.pdf
```

```
└── root/
    ├── index.tsx
    ├── topSection.scss
    ├── topSection.test.tsx
    ├── topSection.stories.tsx
    └── src/
        ├── index.tsx
        ├── hello.md
        ├── doe.md
        ├── nested-folder/
        │   ├── nice.md
        │   ├── nice.tsx
        │   └── nice.py
        └── try-another-folder/
            ├── .gitkeep
            └── world.md

```

This collect the markdowns the way it is structured in vscode

1. hello.md
2. doe.md
3. nice.md
4. world.md

---

## Example: Convert (Extension: PDF)

- If your terminal is in root folder

```
npx @mp5maker/camfsp convert --input src --output documents.pdf --extension pdf
```

```
└── root/
    ├── index.tsx
    ├── topSection.scss
    ├── topSection.test.tsx
    ├── topSection.stories.tsx
    └── src/
        ├── index.tsx
        ├── hello.pdf
        ├── doe.pdf
        ├── nested-folder/
        │   ├── nice.md
        │   ├── nice.tsx
        │   └── nice.py
        └── try-another-folder/
            ├── .gitkeep
            └── world.pdf

```

This collect the markdowns the way it is structured in vscode

1. hello.pdf
2. doe.pdf
3. world.pdf

---

## Example: Collect

- Available Options:

  - input (Required): Folder name
  - output (Required): File name (".pdf")
  - pick (Optional): Specific extensions to extract eg: ".py" ".ts"
  - search (Optional): The term that you are searching for eg: "import os"
  - cut (Optional): Long file names to more readable ones
    - eg: "/User/johndoe/src/hello.md" to "/src/hello.md"
    - by --cut "/User/johndoe"

- Pick (By Default):
  - ".jsx"
  - ".tsx"
  - ".html"
  - "scss"
  - ".css"
  - ".js"
  - ".ts"

* If your terminal is in root folder

```bash
npx @mp5maker/camfsp collect --input src --output documents.pdf --search "<Select" --pick ".js" ".tsx" --cut "root/src"
```

```
└── root/
    ├── index.tsx ("<Select, in the code")
    ├── topSection.scss
    ├── topSection.test.tsx
    ├── topSection.stories.tsx ("<Select, in the code")
    └── src/
        ├── index.tsx
        ├── hello.pdf
        ├── doe.pdf
        ├── nested-folder/
        │   ├── nice.md
        │   ├── nice.js ("<Select, in the code")
        │   └── nice.py
        └── try-another-folder/
            ├── .gitkeep
            └── world.pdf

```

This collect the markdowns the way it is structured in vscode

1. index.tsx
2. topSection.stories.tsx
3. nice.js

---

## Example: Summarize (Local AI)

This feature is only available if you have a local llm

- This will collect all the markdown files and make a summary of it
- Only supported from the models provided by Ollama

* Available Options:

  - input (Required): Folder name
  - output (Required): File name (".pdf")
  - baseurl (Optional): by default, 'http://localhost:11434'
  - model (Optional): by default, 'llama3.1:latest'
  - quiz (Optional): by default, false
    - This will generate a quiz instead of summary
  - ask (Optional): by default, false
    - This will generate answers based on your question
  - Three modes (default, --ask, --quiz), cannot be combined

- If your terminal is in root folder

```bash
npx @mp5maker/camfsp summarize --input src --output documents.pdf --baseurl "http://localhost:11434" --model "llama3.1:latest"
```

---

## Example: Summarize (Local AI: Quiz)

This feature is only available if you have a local llm

- This will collect all the markdown files and make a summary of it
- Only supported from the models provided by Ollama
- If your terminal is in root folder

```bash
npx @mp5maker/camfsp summarize --input src --output documents.pdf --baseurl "http://localhost:11434" --model "llama3.1:latest" --quiz
```

---

## Example: Summarize (Local AI: Ask)

This feature is only available if you have a local llm
* Check ollama list
* If not present then pull it

```bash
ollama pull mxbai-embed-large
```

- This will collect all the markdown files and make a summary of it
- Only supported from the models provided by Ollama
- If your terminal is in root folder

```bash
npx @mp5maker/camfsp summarize --input src --output documents.pdf --baseurl "http://localhost:11434" --model "llama3.1:latest" --ask "Tell me something interesting"
```

## Recommendation (For organizing files)

- Adding numbers with the markdown file name will organize the files better

```
└── root/
    ├── index.tsx
    ├── topSection.scss
    ├── topSection.test.tsx
    ├── topSection.stories.tsx
    └── src/
        ├── 01.hello.md
        ├── 02.doe.md
        ├── nested-folder/
        │   ├── 01-nice.md
        │   ├── 02-ok.md
        │   └── 03.more.md
        └── try-another-folder/
            ├── .gitkeep
            └── 01-world.md

```