mixn / carbon-now-cli

🎨 Beautiful images of your code — from right inside your terminal.
MIT License
5.73k stars 117 forks source link

`widthAdjustment: true` do not exceed 1024px #207

Open am29d opened 4 months ago

am29d commented 4 months ago

Describe the bug When I try to generate image with a long code line, the output image is fixed to 1024p for 1x and 2048p for 2x output size.

To Reproduce Steps to reproduce the behavior:

  1. Run carbon-now with…
  2. Wait for image to download…
  3. See error
  4. Paste code to carbon.now.sh using adjustWidth true
  5. The image is in full width without line breaks

Code I am using

import { BatchProcessor, EventType, processPartialResponse, } from '@aws-lambda-powertools/batch';
import type { SQSEvent, SQSRecord, Context, SQSBatchResponse } from 'aws-lambda';

const processor = new BatchProcessor(EventType.SQS);

const recordHandler = async (record: SQSRecord): Promise<void> => {
  const payload = record.body;
};

export const handler = async (
  event: SQSEvent,
  context: Context
): Promise<SQSBatchResponse> => {
  return processPartialResponse(event, recordHandler, processor, {context});
};

Configuration json file for the cli

{
    "latest-preset": {
        "theme": "night-owl",
        "backgroundColor": "#161E2D",
        "dropShadows": false,
        "exportSize": "1x",
        "firstLineNumber": 1,
        "fontFamily": "Hack",
        "fontSize": "18px",
        "language": "auto",
        "lineHeight": "133%",
        "lineNumbers": true,
        "selectedLines": "*",
        "squaredImage": false,
        "type": "png",
        "watermark": false,
        "widthAdjustment": true,
        "windowControls": false,
        "windowTheme": "none"
    }
}

Expected behavior I expect the tool to not break the line and take as much with as necessary

Screenshots Carbon website manually :

Screenshot 2024-03-21 at 12 37 54

Output using cli batch-cmwtfGg40t

Carbon website using --open-in-browser flag:

Screenshot 2024-03-21 at 12 42 32

Edit: I tried to reduce the fontSize to 14 or 12, but the results are still ab bit weird, but the width seems to be correct:

batch-X2QN56ETIo

Info (please complete the following information):

Code snippet
  
  
mixn commented 1 month ago

Hey @am29d, thanks for opening. Been quite swamped since the beginning of the year, but I will tackle a new release of the CLI soon and, amongst other things, address this (somehow.) 🙂 Thanks for your patience, appreciated!

thomergil commented 1 month ago

Bump... :) I have the same problem. It seems odd that it introduces unnecessary line breaks.

thomergil commented 1 month ago

Turns out, width is an undocumented option for carbon-now.json. I only discovered it because I exported the config from carbon.now.sh. You should add this to the documentation.