Lllm2doc

PDF Generation Test

Status: Ready to generate PDF

Test Content Preview:

Sure! Here are **random C++, PHP, and JavaScript snippets** โ€” diverse enough to test syntax highlighting, special characters, and inline formatting in Word conversion.

---

### ๐ŸŸฆ **C++ Example: PID Controller Simulation**

```cpp
#include <iostream>
#include <cmath>

class PID {
    double Kp, Ki, Kd, prevError, integral;

public:
    PID(double p, double i, double d) : Kp(p), Ki(i), Kd(d), prevError(0), integral(0) {}

    double compute(double setpoint, double measured, double dt) {
        double error = setpoint - measured;
        integral += error * dt;
        double derivative = (error - prevError) / dt;
        prevError = error;
        return Kp * error + Ki * integral + Kd * derivative;
    }
};

int main() {
    PID pid(1.2, 0.4, 0.1);
    double setpoint = 25.0, temp = 20.0;

    for (int t = 0; t < 10; ++t) {
        double control = pid.compute(setpoint, temp, 1.0);
        temp += 0.5 * control;  // simulate heater effect
        std::cout << "t=" << t << " temp=" << temp << " control=" << control << std::endl;
    }
    return 0;
}
```

---

### ๐ŸŸจ **PHP Example: Simple Form Processor**

```php
<?php
if ($_SERVER["REQUEST_METHOD"] === "POST") {
    $name = htmlspecialchars($_POST['name']);
    $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
    $message = trim($_POST['message']);

    if (!empty($name) && !empty($email)) {
        echo "<h2>Thank you, $name!</h2>";
        echo "<p>Your message has been received.</p>";
    } else {
        echo "<p style='color:red;'>Please fill in all fields correctly.</p>";
    }
}
?>

<form method="post">
  Name: <input type="text" name="name" /> <br />
  Email: <input type="text" name="email" /> <br />
  Message: <textarea name="message"></textarea> <br />
  <input type="submit" value="Send" />
</form>
```

---

### ๐ŸŸฉ **JavaScript Example: Async Fetch and Chart Rendering**

```javascript
async function fetchTemperatureData() {
  try {
    const response = await fetch("/api/temperature");
    const data = await response.json();

    const ctx = document.getElementById("chart").getContext("2d");
    new Chart(ctx, {
      type: "line",
      data: {
        labels: data.timestamps,
        datasets: [{
          label: "Temperature (ยฐC)",
          data: data.values,
          borderColor: "rgba(255, 99, 132, 1)",
          fill: false
        }]
      },
      options: {
        responsive: true,
        scales: { y: { beginAtZero: false } }
      }
    });
  } catch (error) {
    console.error("Failed to fetch data:", error);
  }
}

fetchTemperatureData();
```

---

Would you like me to generate a **second batch** with more *edge-case syntax* (e.g. regex, Unicode chars, JSON parsing, template metaprogramming, async/await with exceptions, etc.) โ€” good for testing your parser's robustness?