Code Duplication    Length = 31-31 lines in 2 locations

src/pandoc_numbering/_main.py 2 locations

@@ 1438-1468 (lines=31) @@
1435
                "first-section-level must be positive or zero for category " + category
1436
            )
1437
1438
    if "last-section-level" in definition:
1439
        if isinstance(definition["last-section-level"], MetaString):
1440
            value = definition["last-section-level"].text
1441
        elif (
1442
            isinstance(definition["last-section-level"], MetaInlines)
1443
            and len(definition["last-section-level"].content) == 1
1444
        ):
1445
            value = definition["last-section-level"].content[0].text
1446
        else:
1447
            debug(
1448
                "[WARNING] pandoc-numbering: "
1449
                "last-section-level is not correct for category " + category
1450
            )
1451
            return
1452
1453
        # Get the level
1454
        try:
1455
            level = int(value)
1456
        except ValueError:
1457
            debug(
1458
                "[WARNING] pandoc-numbering: "
1459
                "last-section-level is not correct for category " + category
1460
            )
1461
1462
        if 0 <= level <= 6:
1463
            defined[category]["last-section-level"] = level
1464
        else:
1465
            # pylint: disable=line-too-long
1466
            debug(
1467
                "[WARNING] pandoc-numbering: "
1468
                "last-section-level must be positive or zero for category " + category
1469
            )
1470
1471
@@ 1405-1435 (lines=31) @@
1402
            # Compute the first and last levels section
1403
            defined[category]["first-section-level"] = len(match.group("hidden")) // 2
1404
            defined[category]["last-section-level"] = len(match.group("header")) // 2
1405
    if "first-section-level" in definition:
1406
        if isinstance(definition["first-section-level"], MetaString):
1407
            value = definition["first-section-level"].text
1408
        elif (
1409
            isinstance(definition["first-section-level"], MetaInlines)
1410
            and len(definition["first-section-level"].content) == 1
1411
        ):
1412
            value = definition["first-section-level"].content[0].text
1413
        else:
1414
            debug(
1415
                "[WARNING] pandoc-numbering: "
1416
                "first-section-level is not correct for category " + category
1417
            )
1418
            return
1419
1420
        # Get the level
1421
        try:
1422
            level = int(value) - 1
1423
        except ValueError:
1424
            debug(
1425
                "[WARNING] pandoc-numbering: "
1426
                "first-section-level is not correct for category " + category
1427
            )
1428
1429
        if 0 <= level <= 6:
1430
            defined[category]["first-section-level"] = level
1431
        else:
1432
            # pylint: disable=line-too-long
1433
            debug(
1434
                "[WARNING] pandoc-numbering: "
1435
                "first-section-level must be positive or zero for category " + category
1436
            )
1437
1438
    if "last-section-level" in definition: