github / markup

Determines which markup library to use to render a content file (e.g. README) on GitHub
MIT License
5.86k stars 3.39k forks source link

Markdown: code in ordered list doesn't get formatted #244

Closed simonewebdesign closed 10 years ago

simonewebdesign commented 10 years ago

I've created a test repo for reproducing this bug.

Basically, if I try to add some code in an ordered list by indenting it with 4 spaces, it doesn't get formatted at all.

For example:

  1. Foo
  2. Bar
  3. Code:

    $ git rebase $ git status $ whatever

  4. another point

I was expecting the code to look like this:

$ git rebase
$ git status
$ whatever

Additionally if I use backticks the code gets formatted correctly but without preserving new lines. i.e.:

  1. Foo
  2. Bar
  3. Code:
$ git rebase
$ git status
$ whatever
  1. another point

Hope that makes sense.

bkeepers commented 10 years ago

You actually have to indent the code block 8 spaces when it's in a list. In my experience, this is consistent with other markdown implementations, but I haven't tested it thoroughly.

  1. Foo
  2. Bar
  3. Code:

    $ git rebase
    $ git status
    $ whatever
  4. another point

The fenced code block thing is definitely odd /cc @github/markdown

mdiep commented 10 years ago

You can use a fenced code block, but the first line will need to be indented by 4 spaces. The rule that Markdown uses is that inside a list item, any new block-level elements need to be prefixed by four spaces—because without the four spaces the block-level element would be outside the list.

Code blocks of the non-fenced variety need to be indented 8 because each line could be interpreted as a new paragraph in the list item.

  1. Foo
  2. Bar
  3. Fenced code

    Just the first line
    was indented 4
  4. Indented code block

    All the lines
    are indented 8
  5. Another point

Having said that, the example you gave should not be rendering like that. But I don't believe that it's a github/markup issue because markup supports multiple markdown implementations.

rowifi commented 3 years ago

Here's the code:

/*
 An example digital clock using a TFT LCD screen to show the time.
 Demonstrates use of the font printing routines. (Time updates but date does not.)

 For a more accurate clock, it would be better to use the RTClib library.
 But this is just a demo. 

 This examples uses the hardware SPI only. Non-hardware SPI
 is just too slow (~8 times slower!)

 Based on clock sketch by Gilchrist 6/2/2014 1.0
 Updated by Bodmer
A few colour codes:

code  color
0x0000  Black
0xFFFF  White
0xBDF7  Light Gray
0x7BEF  Dark Gray
0xF800  Red
0xFFE0  Yellow
0xFBE0  Orange
0x79E0  Brown
0x7E0 Green
0x7FF Cyan
0x1F  Blue
0xF81F  Pink
 */

#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
#include <SPI.h>

#include <WiFiClient.h>
// For WiFi Autoconnect
#include <WebServer.h>     // For Wifi Autoconnect WebServer.h for ESP32
#include <AutoConnect.h>  // For Wifi Autoconnect
#include <ESPmDNS.h>      // For Wifi Autoconnect

#define EEPROM_SIZE 50

#define EE_ADDRESS_storedfrequency 0

#define EE_ADDRESS_storedprotectioncount 8
#define EE_ADDRESS_storedprotectionactive 12
#define EE_ADDRESS_storedanaloguepeak 16

TFT_eSPI tft = TFT_eSPI();  // Invoke library, pins defined in User_Setup.h

  // For WiFi Autoconnect
WebServer Server;          // Replace with WebServer for ESP32
AutoConnect      Portal(Server);
AutoConnectConfig Config;

uint32_t targetTime = 0;       // for next 1 second timeout
uint32_t targetfastTime = 0;       // for next fast second timeout

byte omm = 99;
boolean initial = 1;
byte xcolon = 0;
unsigned int colour = 0;

unsigned int storedanaloguepeak;

const int pwmFreq = 5000;
const int pwmResolution = 8;
const int pwmLedChannelTFT = 0;

const int pwmLedChannelA = 1;
const int pwmLedChannelB = 2;
const int pwmLedChannelC = 3;

const int LEDA = 21; // Pin Number
const int LEDB = 22; // Pin Number
const int LEDC = 17; // Pin Number
const int MONITOR = 2; // Pin Number

//const int FSYNC = 5;//10;                       // Standard SPI pins for the AD9833 waveform generator.
//const int CLK = 18;// 13;                         // CLK and DATA pins are shared with the TFT display.
//const int DATA = 23; // 11;

const int EraseButtonPin = 25;

void rootPage() {
  char content[] = "Hello, world webpage from ESP";
  Server.send(200, "text/plain", content);
}

uint16_t wn;

static uint8_t conv2d(const char* p) {
  uint8_t v = 0;
  if ('0' <= *p && *p <= '9')
    v = *p - '0';
  return 10 * v + *++p - '0';
}

uint8_t hh=conv2d(__TIME__), mm=conv2d(__TIME__+3), ss=conv2d(__TIME__+6);  // Get H, M, S from compile time

void setup(void) {

  Serial.begin(115200);   
  Serial.println(" START");
  //nvs_flash_init();

  EEPROM.begin(EEPROM_SIZE); 

  tft.init();
  tft.setRotation(1);
  tft.fillScreen(TFT_BLACK);

  tft.setTextColor(TFT_YELLOW, TFT_BLACK); // Note: the new fonts do not draw the background colour

  targetTime = millis() + 1000; 

  pinMode (EraseButtonPin,INPUT_PULLUP);
  pinMode(LEDA, OUTPUT);
  pinMode(LEDB, OUTPUT);
  pinMode(LEDC, OUTPUT);

  wifisetup();

// LED Backlight PWM
  ledcSetup(pwmLedChannelTFT, pwmFreq, pwmResolution);
  ledcAttachPin(TFT_BL, pwmLedChannelTFT);
  ledcWrite(pwmLedChannelTFT, 128);

//Other PWM
  ledcSetup(pwmLedChannelA, pwmFreq, pwmResolution);
  ledcAttachPin(LEDA, pwmLedChannelA);
  ledcWrite(pwmLedChannelA, 128);

//Other PWM
  ledcSetup(pwmLedChannelB, pwmFreq, pwmResolution);
  ledcAttachPin(LEDB, pwmLedChannelB);
  ledcWrite(pwmLedChannelB, 128);  

//Other PWM
  ledcSetup(pwmLedChannelC, pwmFreq, pwmResolution);
  ledcAttachPin(LEDC, pwmLedChannelC);
  ledcWrite(pwmLedChannelC, 128);

}

// DONT NEED THIS - Autoconnect erases the wificonfi - 
// but this IS needed once the Wifi is connected and you want to manually disconnect
void erase_mycredentials(){

  WiFi.begin("0","0");
  WiFi.disconnect(); // clear credentials
  delay(1000); 
  ESP.restart();
}

bool startCP(IPAddress ip) {
      tft.setTextColor(TFT_BLUE, TFT_BLACK);
      tft.drawCentreString("SETUP WIFI",120,48,2); // Next size up font 2
  Serial.println("C.P. started, IP:" + WiFi.localIP().toString());
  return true;
}

void wifisetup (){

     // check for forced portal on restart
     if (digitalRead(EraseButtonPin) == 0){ 
    Serial.println("Start Portal");
    Config.autoReconnect = true;
    Config.autoRise = true;
    Config.immediateStart = true;

      }
      else
      {
    Serial.println("Start Normal");      
    Config.autoReconnect = true;
    Config.autoRise = false;

      }

    Portal.onDetect(startCP); // Callback if Captive portal started
    Portal.config(Config);

    if (Portal.begin()) { // remove local portal
    Serial.println("HTTP server:" + WiFi.localIP().toString());
    WiFi.softAPdisconnect(true);
      }

    while (WiFi.status() != WL_CONNECTED) {
        //delay(500);
        delay(1000);
        Serial.print(".");

    }

    Serial.println("\nConnected.\n");

}

void loop() {

  storedanaloguepeak++;

  if (targetTime < millis()) {
    targetTime = millis()+1000;
    ss++;              // Advance second
    if (ss==60) {
      ss=0;
      omm = mm;
      mm++;            // Advance minute
      if(mm>59) {
        mm=0;
        hh++;          // Advance hour
        if (hh>23) {
          hh=0;
        }
      }
    }

    if (ss==0 || initial) {
      initial = 0;
      tft.setTextColor(TFT_GREEN, TFT_BLACK);
      tft.setCursor (8, 52);
      tft.print(__DATE__); // This uses the standard ADAFruit small font

      tft.setTextColor(TFT_BLUE, TFT_BLACK);
      tft.drawCentreString("It is windy",120,48,2); // Next size up font 2

      //tft.setTextColor(0xF81F, TFT_BLACK); // Pink
      //tft.drawCentreString("12.34",80,100,6); // Large font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 . : a p m
    }

    // Update digital time
    byte xpos = 6;
    byte ypos = 0;
    if (omm != mm) { // Only redraw every minute to minimise flicker
      // Uncomment ONE of the next 2 lines, using the ghost image demonstrates text overlay as time is drawn over it
     // tft.setTextColor(0x39C4, TFT_BLACK);  // Leave a 7 segment ghost image, comment out next line!
      tft.setTextColor(TFT_BLACK, TFT_BLACK); // Set font colour to black to wipe image
      // Font 7 is to show a pseudo 7 segment display.
      // Font 7 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : .
      tft.drawString("88:88",xpos,ypos,7); // Overwrite the text to clear it
      tft.setTextColor(0xFBE0); // Orange
      omm = mm;

      if (hh<10) xpos+= tft.drawChar('0',xpos,ypos,7);
      xpos+= tft.drawNumber(hh,xpos,ypos,7);
      xcolon=xpos;
      xpos+= tft.drawChar(':',xpos,ypos,7);
      if (mm<10) xpos+= tft.drawChar('0',xpos,ypos,7);
      tft.drawNumber(mm,xpos,ypos,7);
    }

    if (ss%2) { // Flash the colon
      tft.setTextColor(0x39C4, TFT_BLACK);
      xpos+= tft.drawChar(':',xcolon,ypos,7);
      tft.setTextColor(0xFBE0, TFT_BLACK);
    }
    else {
      tft.drawChar(':',xcolon,ypos,7);

 #if 0     
      colour = random(0xFFFF);
      // Erase the old text with a rectangle, the disadvantage of this method is increased display flicker
      tft.fillRect (0, 64, 160, 20, TFT_BLACK);
      tft.setTextColor(colour);
      tft.drawRightString("Colour",75,64,4); // Right justified string drawing to x position 75
      String scolour = String(colour,HEX);
      scolour.toUpperCase();
      char buffer[20];
      scolour.toCharArray(buffer,20);
      tft.drawString(buffer,82,64,4);
#endif

    //  String mytext = "mytext";
   //   char buffer[20];
    //  mytext.toCharArray(buffer,20);

    //  ltoa(storedanaloguepeak,buffer,10);

    //  tft.setTextColor(TFT_BLUE, TFT_BLACK);
    //  tft.drawRightString(buffer,75,64,4); // Right justified string drawing to x position 75
    //  tft.drawNumber(storedanaloguepeak,75,64,4);

    }
  }

  if (targetfastTime < millis()) {
    targetfastTime = millis()+100;

      tft.setTextColor(TFT_BLUE, TFT_BLACK);
    //  tft.drawRightString(buffer,75,64,4); // Right justified string drawing to x position 75
      tft.drawNumber(storedanaloguepeak,75,64,4);

    if (WiFi.status() == WL_CONNECTED){
      tft.drawChar(0,85,wn++,TFT_BLUE,TFT_BLACK,4);
    }
  }

}